28. Januar 2009 16:47
28. Januar 2009 16:57
28. Januar 2009 17:01
EVALUATE (Variable)
Use this function to evaluate a string representation of a value into its normal representation. The system assigns the result to a variable.
[Ok :=] EVALUATE(Variable, String[, Number])
Ok
Data type: boolean
A return code that tells you whether or not an error occurred during the evaluation of the string.
If Ok is...
It means...
TRUE
No errors occurred during the evaluation of the string. The system assigned the value to Variable.
FALSE
Errors occurred during the evaluation of the string. The system did not modify the original value of Variable.
If you omit this optional return value and an error occurs during the evaluation of the string, a run-time error occurs. If you include it, the system assumes you will handle any errors.
Variable
Data 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
Data type: text constant or code
A string containing a value of any simple C/AL data type.
Number
Data type: integer
This optional value can be used when exporting data with an XMLport. The only valid value is 9 and this indicates that the data must be converted from XML format to C/SIDE format.
Example
This example shows how the EVALUATE function works when called with three different types of variables.
Value := '010196';
Ok1 := EVALUATE(VarInteger, Value);
Ok2 := EVALUATE(VarDate, Value);
Ok3 := EVALUATE(VarYesNo, Value);
MESSAGE(Text000 + Text001 + Text002,
VarInteger, Ok1, VarDate, Ok2, VarYesNo, Ok3)
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'
The message window shows:
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 the system can interpret Value ('010196') as both an integer and a date expression, it cannot interpret it as a boolean expression. This causes an error, shown in the return code Ok3 (=FALSE).
IsNumeric := EVALUATE(MyIntVariable, MyStringVariable);
28. Januar 2009 17:02
28. Januar 2009 17:03
28. Januar 2009 17:03
stryk hat geschrieben:da war ich wohl zu langsam ...