EVALUATE Function

Evaluates a string representation of a value into its normal representation. The result is assigned to a variable.

[Ok :=] EVALUATE(Variable, String[, Number])

Parameters

  • Variable
    Type: Boolean, integer, option, date, time, text constant, code, or GUID

    Any type of variable. The value of the string is assigned to the variable

  • String
    Type: Text constant or code

    A string containing a value of any simple C/AL data type

  • Number
    Type: Integer

    This optional value can be used when exporting data with an XMLport. The only valid value is 9, which indicates that the data must be converted from XML format to C/SIDE format.

Property Value/Return Value

Type: Boolean

Specifies whether an error occurred during the evaluation of the string.

If the return value is true, then no errors occurred during the evaluation of the string and the value was assigned to Variable.

If the return value is false, then errors occurred during the evaluation of the string and the original value of Variable was not modified.

Example

This example shows how to use the EVALUATE function when called with three different types of variables.

This example requires that you create the following text constants in the C/AL Globals window.

Text constant ENU value

Text000

'VarInteger = #1######, and the return code is: %2\'

Text001

'VarDate = #3######, and the return code is: %4\'

Text002

'VarYesNo = #5######, and the return code is: %6'

Value := '010196';
Ok1 := EVALUATE(VarInteger, Value);
Ok2 := EVALUATE(VarDate, Value);
Ok3 := EVALUATE(VarYesNo, Value);
MESSAGE(Text000 + Text001 + Text002, VarInteger, Ok1, VarDate, Ok2, VarYesNo, Ok3)

The message window displays the following:

VarInteger = 10196 , and the return code is: Yes

VarDate = 01/01/96, and the return code is: Yes

VarYesNo = No , and the return code is: No

This example shows that while Value ('010196') can be interpreted as both an integer and a date expression, it cannot be interpreted as a Boolean expression. This causes an error, shown in the return code Ok3 (=FALSE).

See Also

Reference

CLEAR Function
CLEARALL Function
COPYSTREAM Function (InStream, OutStream)