EVALOPT parameter

From m204wiki
Jump to navigation Jump to search

Evaluation options

Summary

Default value
0
Maximum value
255
Parameter type
User
Where set
Any user
Introduced
V7.8 (Options 2, 4, and 8 added in V7.9) (Options X'80 and X'40 added in V8.0)

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, Cancel procedure and issue M204.2985 if a null is added to a collection.
X'10' If on, Turn off target autonew on any assignment.
X'20' If on, Cancel procedure and issue M204.3057 if a field occurrence does not exist.
X'40' If on, an M204.2985 will be issued on truncation of a fixed numeric variable from any numeric variable.
X'80' If on, M204.2985 will be issued when automatic conversion of a string to a fixed numeric variable is truncated. This condition normally results in a 0 being assigned to the target.

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