EVALOPT parameter

From m204wiki
Jump to navigation Jump to search

Evaluation options

Summary

Default value
0
Maximum value
15
Parameter type
User
Where set
Any user
Introduced
V7.8 (Options 2, 4, and 8 added in V7.9)

Description

The EVALOPT user parameter allows one to trap conditions that might be indicative of application errors. If one of the conditions trapped by EVALOPT is encountered, a "M204.2985: EVALOPT trapped error" message is issued. This message can be MSGCTL'ed to cause request cancellation to ensure that application don't continue after a condition trapped by this facility is encountered.

The bits in EVALOPT have the following meanings:

X'01' If on, a M204.2985 will be issued on an assignment of a string to a variable not long enough to hold it. This condition normally results in truncation of the source string.
X'02' If on, a M204.2985 will be issued when automatic conversion of a string to a number encounters a string that is not a valid representation of a number. This condition normally results in a 0 being assigned to the target.
X'04' If on, M204.2985 will be issued when automatic conversion of a string to a number encounters an empty (zero-length) string. This condition normally results in a 0 being assigned to the target.
X'08' If on, an M204.2985 will be issued on attempt to add a null object to a collection (Arraylist or NamedArraylist).

For example, consider the following code:

%v is string len 2 initial('ST') %s is string len 1 %f is float %n is float %s = %v %f = %v %n = " printtext {~} = {%s} printtext {~} = {%f} printtext {~} = {%n}

If EVALOPT is set to 0 (default), then the above code would allow silent truncation and give the result:

%s = S %f = 0 %n = 0

If EVALOPT is set to 1 , then the above code is cancelled with the following message:

M204.0552: Variable too small for result

If EVALOPT is set to 2 or 4 , then the above code is cancelled with the following message:

M204.2985: Invalid numeric conversion