Return Values, Status Values, and ProcScript Errors
ProcScript modules return a numeric status value in $status. This function may contain the value given as an argument to the return or exit statement, a value that indicates successful completion of a command or module, or a negative number that reflects an error.
For example:
return -1 ; $status = -1 exit -5 ; $status = -5
Using return or exit without an argument sets $status to 0
.
Return Values from Triggers
The return value from a trigger affects the process in which the trigger was activated. For example, if a negative value is returned by a write trigger, the store process stops and no further write and delete triggers are activated. For more information, see Trigger Activation.
When a series of nested trigger activations (started, for example, with the statement retrieve, store, erase, or validate) is stopped because the ProcScript has placed a negative value in $status, the $procerror function contains the error constant <UGENERR_4GL_SAYS_ERROR>. This allows you to determine if the triggers stopped with a real error or with a user-defined error.
Return Values from Statements and Functions
If an error occurs during the execution of a ProcScript statement or function, the function $procerror is set to a unique negative value; the function $procerrorcontext gives details about where the error occurred.
For compatibility with versions of Uniface prior to V7.2, the function $status is also set to a negative value. However, because $status can also be set directly with ProcScript, it is recommended that you use this only in combination with $procerror to determine the exact cause of an error.
Some ProcScript statements and functions return a non-negative value in $status. These usually provide extra information about the result of the statement or function, such as the number of items copied from a list. In addition, some ProcScript statements return data in $result. (The return values for individual statements and functions are given in the command descriptions. For more information, see ProcScript: Statements and ProcScript: Functions.)
Return Values from Operations and Entries
When an operation or entry is invoked,
$status is reset to 0
. The value of $status
can be changed by statements in the ProcScript module or explicitly assigned a value, but the
entry and operation statements themselves do not affect
$status.
Note: Assigning a value to $status is not recommended. It resets the current value of $procerror, so the ProcScript error status and context are lost.
To pass codes to another ProcScript module or component, use the return statement to have the module return a specific value.
If the module was invoked by a statement, such as call or activate, the return value of the module is assigned to $status.
If the module was invoked using an inline construction (such as an instance handle or a function argument), the return value is returned inline. The value of $status keeps the value as set inside the Proc module. For example:
-
Assign the return value of an operation to a variable:
vReturn = $instancehandle->myOper()
In this case, the return value is assigned to the
vReturn
variable. . -
Use the return value of an entry as an argument to a Proc statement:
message/info myEntry()
In this case, the return value is displayed in a message dialog.
For examples of the effect of return values and $status, see Activating Operations Using Handles.