EVALOPT parameter: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "{{Template:EVALOPT parameter subtitle}} ==Summary== <dl> <dt>Default value <dd>0 <dt>Maximum value <dd>1 <dt>Parameter type <dd>System <dt>Where set <dd>Any user <dt>Introduc...")
 
No edit summary
 
(11 intermediate revisions by 3 users not shown)
Line 6: Line 6:
<dd>0
<dd>0
<dt>Maximum value
<dt>Maximum value
<dd>1
<dd>15
<dt>Parameter type
<dt>Parameter type
<dd>System
<dd>User
<dt>Where set
<dt>Where set
<dd>Any user
<dd>Any user
<dt>Introduced
<dt>Introduced
<dd>V7.8  
<dd>V7.8 (Options 2, 4, and 8 added in V7.9)
</dl>
</dl>


==Description==
==Description==
Controls the cancellation of a request on truncation of string data.
The <var>EVALOPT</var> user parameter allows one to trap conditions that might be indicative of application errors. If one of the conditions trapped by <var>EVALOPT</var> 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.
For example, with the default of 0 in place, the following code <p class="code">    %x is string len 1 
    %y is string len 2 
    %y = 'ab'          
    %x = %y             
    printtext {~} = {%x} </p>


would cause silent truncation, and give the result
The bits in <var>EVALOPT</var> have the following meanings:
    <p class="code">%x = a </p>
 
If <var>EVALOPT</var> is set to 1, then the above code produces the following message:
    <p class="code">M204.0552: Variable too small for result </p>
 
and the request is cancelled.


<table class="thJustBold">
<tr><th>X'01'</th>
<td>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.</td></tr>
<tr><th>X'02'</th>
<td>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.</td></tr>
<tr><th>X'04'</th>
<td>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.</td></tr>
<tr><th>X'08'</th>
<td>If on, an M204.2985 will be issued on attempt to add a <var>null</var> object to a collection (Arraylist or NamedArraylist). </td></tr>
</table>
<p>
For example, consider the following code:
<p class="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}  </p>
If <var>EVALOPT</var> is set to 0 (default), then the above code would allow silent truncation and give the result:
<p class="code">%s = S 
%f = 0 
%n = 0    </p>
If <var>EVALOPT</var> is set to 1 , then the above code is cancelled with the following message:
    <p class="code">M204.0552: Variable too small for result </p>
If <var>EVALOPT</var> is set to 2 or 4 , then the above code is cancelled with the following message:
    <p class="code">M204.2985: Invalid numeric conversion </p>


[[Category:User parameters]]
[[Category:Parameters]]
[[Category:Parameters]]

Latest revision as of 13:40, 4 December 2023

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