See Also: Type Conversion Functions, Data Types. Functions and Constants
The Convert function returns a variable of the specified type that is the best conversion from the original variable. Note that Type Conversion Functions, such as Integer or String for a known target data type are more commonly used.
Specified type
Convert( {Var}, {Type} )
Where:
{Var} can be a variable of any data type, but not an expression or a constant value
Procedure testConvert
UInteger u
Real r
move 3.1415 to r
// Move Real r to Unsigned Integer u, decimals will drop off
move (Convert(r, UInteger)) to u
Send Info_Box u "Result"
End_Procedure
The difference between Convert and Cast apply primarily to data-overflow situations such as changing an integer with a large value to a short. When a number doesn't fit you get an error with Convert and not with Cast. Strings are special. When you cast or convert from a string they do the same thing, which is to not raise data-range errors. However, if the format of your string is invalid, you get an error with Cast or Convert.
If a conversion error occurs, error 4381 will be reported.