return
Exit from the ProcScript module, optionally returning a value to $status.
return {Expression}
Example: return (0)
Parameters
Parameter | Data Type | Description |
---|---|---|
Expression | Any | Expression that evaluates to any data type. The value is placed in $status (and automatically converted to a numeric if the data type is not numeric). To improve readability, parentheses () are often included as a part of Expression. |
Return Values
Value | Meaning |
---|---|
0
|
Expression is not present, or is converted from a data type that cannot be expressed as a number. |
>0 |
Value of Expression if it evaluates to a numeric. |
$procerror is 0
.
Use
Allowed in all component types.
Description
The return statement exits from the ProcScript module, and returns the specified value.
If you use Expression to return a value, you should be aware that in many triggers, returning a negative value causes the cursor to remain in the field. For more information, see the descriptions of the individual triggers.
If the module was invoked by a statement, such as call or activate, the return value of the module is assigned to $status (and automatically converted to a numeric if the data type is not numeric).
If the module was invoked using an inline
construction (such as an instance handle or a function argument), the return value is returned
inline, and the value of $status keeps the value as set inside the ProcScript
module. If this was not changed, it remains 0
, which is the value set when the
module was invoked.
Note: For entries, you can specify the data type of the return value using the returns declaration before the parameters block. For operations, the return value of an operation is always Numeric.
Using return
The following example uses the return statement to prevent the user from quitting a modified form without confirming the action:
trigger quit ; check for modifications: if no changes ; end and set $status = 0 ; return -1 prevents user from leaving form if ($formmod = 0) return else askmess "Data modified! Do you want to store? (Y/N)" if ($status = 1) store if ($status < 0) message "Store error number %%$status%%%" return (-1) endif else return (0) ;leave form without storing endif endif end ; quit
Version | Change |
---|---|
9.6.02 | If Expression is specified, it can evaluate to any data type, not just numeric. To make use of this change, you must recompile your code. |