Chapter 50 Caché Command Encyclopedia ZQUIT (Old Version) Command

Chapter 50 Caché Command Encyclopedia ZQUIT (Old Version) Command

Exit the program with error handling.

Focus

  1. ZQUITCan 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 ZQUITthe ZQabbreviation.

Note: Describes the old version of the ZQUITcommand. 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 ZTRAPcommands with $ZERRORparameters to pass control between error handlers. ZQUITCommands in the new procedure code will cause errors.

ZQUITThe command exits the encoding routine and provides explicit control for error handling.

Each execution DO, FORor the XECUTEcommand or the user-defined function call, the program will Caché stack (sometimes referred to as "call stack") is placed in the return information. ZQUITProvides a mechanism through which nested error handling routines can pass control to higher-level error handling programs. ZQUITRe-sign the error status and cause Caché to dissolve the program (call) stack.

ZQUITQUITSimilar to the command, but it provides explicit control error handling. Unlike QUITcommands, they ZQUITcan only be used in coding routines. When prompted for input from the terminal, Caché ignores it ZQUIT.

ZQUITThere are two forms:

  • With parameters
  • No parameters

ZQUIT has no parameters

ZQUITClear the entire stack without parameters .

ZQUIT has parameters

ZQThe expression uses $ZTRAPan error handler to expand the stack to another call stack level. The value of expression ZQUITspecifies 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 $ZTRAPhandler encountered . If you use 2 as an expression, Caché will expand the stack to the second $ZTRAPhandler 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. $ZTRAPThe 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 ZQUITbehavior

If you do not specify any parameters, it ZQUITwill 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.

ZQUITThe control flow is not changed. Use ZQUITthe 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 ZQthere are two spaces after it.

If the job starts in programmer mode, the QUITcommand will return to programmer mode; if the job starts in application mode, the QUITcommand will exit. To log application errors, use the following command to end the error trap code:

   ZQ  GOTO ^%ET

Again, please pay attention to ZQthe two spaces after it.

ZQUIT's behavior and parameters

When specified with parameters, the ZQUITentire stack will not be cleared, but one or more levels will be cleared back to the level where $ZTRAPspecial 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. $ZTRAPDirect error trapping to the routine where the routine is set.

Example

   ZQ 1

Clear the stack back to $ZTRAPthe previous level set . To ZQUITpass parameters, "2" will clear the stack back to set $ZTRAPthe reciprocal of the second level, and so on.

Caché $ZTRAPcontinues program execution at the execution level that contains the error trap routines currently set in. When the error trap routine exits, control will $ZTRAPreturn to the QUITsame position as the set subroutine .

If Caché $ZTRAPshould find $ETRAPthe 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 $ETRAPerror handler. If the $ETRAPerror handler can not eliminate the error, the original issue ZQUITof $TRAPan error handler will get control again. At this time, the $ZTRAPerror handler can use the GOTOcommand to transfer control to the originally designated $ZTRAPhandler.

Note: Do not use indirect GOTO (for example ZQ 1 GOTO @ $ZT) in procedures or object methods with default ProcedureBlock properties . This will cause compilation errors because the GOTOexit 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.

ZQUITThis error return sequence can be changed in any of the following ways :

  • ZQ 1 QUIT( ZQ 1Exit)—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( ZQExit)—Pause the application program or enter an empty program stack in the program mode. Please note ZQUITand QUITtwo spaces between.
  • ZQ GOTO ^ routine-Clear the program stack and resume execution on the specified top-level routine (usually a function driver). Please note ZQUITand GOTOtwo spaces between.

Guess you like

Origin blog.csdn.net/yaoxin521123/article/details/108092950