Automatic Type Conversion

DataFlex supports automatic type conversion among variables and tokens of most of the DataFlex simple types (Integer, Number, Real, etc.). Examples of DataFlex type conversion are:

Integer iTest

Move "123"  To iTest

In the above example an integer variable is declared then it is assigned a string token "123". The result is that the integer 123 is stored into the integer variable. However, the following example will generate a runtime error.

Integer iTest

Move "XX123" To iTest

The reason for the error is that DataFlex is unable to interpret the string "XX123" as an integer.

Further examples of automatic type conversion are:

Number  nTest

Integer iTest

String  sTest

Date    dTest

 

Move 2.001e3    To nTest    // 2001.0 is stored in nTest

Move nTest      To iTest    // 2001 is stored in iTest

Move 01/01/2001 To dTest

Move dTest      To sTest    // "01/01/2001 is stored in sTest

See Also

Type Conversion Functions