A cast allows you to explicitly change the type of an expression. Casts are used when you know the type of expression you need, and want the compiler to carry out the conversion. Use the following syntax to perform a cast:
type – Specifies the resulting type of the expression. This can be integer, long, currency, vcurrency, string or boolean.
expression – The expression whose type is being converted.
Some casts are not permitted. For example, you can’t use a cast to convert a currency expression into a date expression. Invalid casts will compile, but will generate errors at runtime.
The following example converts the value 15 to a long integer.
local long long_int_val; long_int_val = long(15);
The following example converts the string “45.12” to a currency value. Because the value() function returns a variable currency value, a cast is used to convert the result to a currency.
local currency cur_val; cur_val = currency(value("45.12"));