Article Directory
Chapter 50 Caché Command Encyclopedia ZQUIT (Old Version) Command
Exit the program with error handling.
Focus
ZQUIT
Can only be used in coding routines
Outline
ZQ:pc expression
parameter
- pc optional-post condition expression.
- expression Optional-expression, the result of which is an integer greater than 0.
description
Caché platform recognizes only ZQUIT
the ZQ
abbreviation.
Note: Describes the old version of the ZQUIT
command. Starting from Caché 5.1, ZQUIT commands are considered old commands and should not be used in new programming. It is described here only for compatibility with older applications. The new program should use ZTRAP
commands with $ZERROR
parameters to pass control between error handlers. ZQUIT
Commands in the new procedure code will cause errors.
ZQUIT
The command exits the encoding routine and provides explicit control for error handling.
Each execution DO
, FOR
or the XECUTE
command or the user-defined function call, the program will Caché stack (sometimes referred to as "call stack") is placed in the return information. ZQUIT
Provides a mechanism through which nested error handling routines can pass control to higher-level error handling programs. ZQUIT
Re-sign the error status and cause Caché to dissolve the program (call) stack.
ZQUIT
QUIT
Similar to the command, but it provides explicit control error handling. Unlike QUIT
commands, they ZQUIT
can only be used in coding routines. When prompted for input from the terminal, Caché ignores it ZQUIT
.
ZQUIT
There are two forms:
- With parameters
- No parameters
ZQUIT has no parameters
ZQUIT
Clear the entire stack without parameters .
ZQUIT has parameters
ZQ
The expression uses $ZTRAP
an error handler to expand the stack to another call stack level. The value of expression ZQUIT
specifies the number of stack levels specified by the unwinding handler. If you use 1 as an expression, Caché will expand the stack to the first $ZTRAP
handler encountered . If you use 2 as an expression, Caché will expand the stack to the second $ZTRAP
handler encountered , and so on.
parameter
pc
Optional post condition expression. If the post-conditional expression is true (calculated as a non-zero value), Caché executes the command. If the post-conditional expression is false (calculated as zero), Caché does not execute the command.
expression
Any calculated valid CachéObjectScript expression for an integer greater than 0. $ZTRAP
The setting used by the Caché platform clears the program stack back to the setting indicated by the resulting integer.
Example
The following is an example of a tape reading routine that reads the record into x, and if the tape mark is read ("expected" error), it returns the tape mark flag (tm) as TRUE (1) and allows it to be called The error trap routine of the author, if any, handle any other errors:
Mtread
SET $ZTRAP="Mterr"
USE 47
READ x
SET tm=0
QUIT ; Normal return
Mterr
IF $ZERROR?1"<MAGTAPE>" ; 模式匹配:repcount stringliteral
{
} ; 自动跳转到错误陷阱处理程序
ELSE {
SET tm=123
}
IF tm=1 {
QUIT
} ELSE {
ZQ 1
}
IF $ZTRAP'="" {
GOTO @$ZTRAP
} ELSE {
; 调用者的错误例程
; 没有呼叫者的错误例程
USE 0
WRITE !,$ZERROR ZQ
QUIT
}
note
Parameterless ZQUIT
behavior
If you do not specify any parameters, it ZQUIT
will expand the entire stack. Execution continues at the main program level; that is, the level at which the job starts in terminal mode or application mode.
ZQUIT
The control flow is not changed. Use ZQUIT
the CachéObjectScript command to continue execution. In order to simulate the error trap behavior of M/11, the error handling routine should end with the following command
ZQ QUIT
Please note that ZQ
there are two spaces after it.
If the job starts in programmer mode, the QUIT
command will return to programmer mode; if the job starts in application mode, the QUIT
command will exit. To log application errors, use the following command to end the error trap code:
ZQ GOTO ^%ET
Again, please pay attention to ZQ
the two spaces after it.
ZQUIT's behavior and parameters
When specified with parameters, the ZQUIT
entire stack will not be cleared, but one or more levels will be cleared back to the level where $ZTRAP
special variables are set . The number of levels is specified by the expression parameter, and the value of the expression parameter must be an integer greater than 0. $ZTRAP
Direct error trapping to the routine where the routine is set.
Example
ZQ 1
Clear the stack back to $ZTRAP
the previous level set . To ZQUIT
pass parameters, "2" will clear the stack back to set $ZTRAP
the reciprocal of the second level, and so on.
Caché $ZTRAP
continues program execution at the execution level that contains the error trap routines currently set in. When the error trap routine exits, control will $ZTRAP
return to the QUIT
same position as the set subroutine .
If Caché $ZTRAP
should find $ETRAP
the error handler specified by the special variable at the stack level before reaching the stack level of the specified error handler, Caché passes control to the $ETRAP
error handler. If the $ETRAP
error handler can not eliminate the error, the original issue ZQUIT
of $TRAP
an error handler will get control again. At this time, the $ZTRAP
error handler can use the GOTO
command to transfer control to the originally designated $ZTRAP
handler.
Note: Do not use indirect GOT
O (for example ZQ 1 GOTO @ $ZT
) in procedures or object methods with default ProcedureBlock properties . This will cause compilation errors because the GOTO
exit procedure cannot be used . Existing routines using this construction should not be converted into procedures. The ProcedureBlock attribute must be used to exclude object methods using this construction.
ZQUIT
This error return sequence can be changed in any of the following ways :
ZQ 1 QUIT
(ZQ 1
Exit)—Returns to the caller of the subroutine that set the previous error trap.ZQ 1 GOTO @ $ZT
-Call the previous error trap routine.ZQ QUIT
(ZQ
Exit)—Pause the application program or enter an empty program stack in the program mode. Please noteZQUIT
andQUIT
two spaces between.ZQ GOTO ^ routine
-Clear the program stack and resume execution on the specified top-level routine (usually a function driver). Please noteZQUIT
andGOTO
two spaces between.