16. Mai 2008 11:57
MischprotokolleMH.Artnr := ADOrs.Fields.Item('Artnr').Value;
16. Mai 2008 12:06
C/SIDE Reference Guide hat geschrieben: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).
16. Mai 2008 12:09
IF EVALUATE(i, ADOrs.Fields.Item('Reznr').Value) THEN
MischprotokolleMH.Reznr := i;
16. Mai 2008 12:50
IF NOT EVALUATE(MischprotokolleMH.Reznr, ADOrs.Fields.Item('Reznr').Value) THEN BEGIN
// z.B. eine Hinweismeldung der Art "Umwandlung nicht erfolgt");
END;
16. Mai 2008 14:28
MESSAGE(FORMAT(ADOrs.Fields.Item('Protokoll').Value));
16. Mai 2008 14:39
TextTmp := ADOrs.Fields.Item('Reznr').Value;
IF EVALUATE(IntTmp, TextTmp) THEN
MischprotokolleMH.Reznr := IntTmp;
16. Mai 2008 15:07
16. Mai 2008 16:22
16. Mai 2008 16:46
17. Mai 2008 13:30
VariantTmp := ADOrs.Fields.Item('Reznr').Value;
IF EVALUATE(IntTmp, FORMAT(VariantTmp)) THEN
MischprotokolleMH.Reznr := IntTmp;
19. Mai 2008 11:27
19. Mai 2008 16:22
IF EVALUATE(i, FORMAT(VariantTmp)) THEN
26. Mai 2008 10:45
VarianttoInteger(AVariant : Variant) RetInt : Decimal
IF ISCLEAR(ADOStream) THEN
CREATE(ADOStream);
ADOStream.Open;
ADOStream.WriteText(AVariant);
ADOStream.Position:= 0;
EVALUATE(RetInt,ADOStream.ReadText);
ADOStream.Close;
EXIT(RetInt);
NavTab.Protokoll := VariantToInteger(ADOrs.Fields.Item('Protokoll').Value);