How can I convert a currency to a Number in SilkTest?
On occasion returning values from a web page or application may result in a string representation of a number or currency being returned. If these require manipulated in any way (such as adding them for verification of a total) this will not be possible in the current format. The following function and example shows how the formatting can be removed and a number returned.
[-] number CurrencyToNumber (string sString) [ ] [ ] string sRemoveCurrency = stuff (sString ,1,1,"") [ ] [-] while (StrPos (",", sRemoveCurrency) > 0 ) [ ] [ ] sRemoveCurrency = stuff (sRemoveCurrency ,StrPos (",", sRemoveCurrency),1,"") [ ] [ ] return (val(ltrim(sRemoveCurrency))) [ ] [-] testcase Test1() appstate none [ ] [ ] print(CurrencyToNumber ("$ 5,900,111,111.00"))