IB Statements/popall

From CometWiki

< IB Statements
Revision as of 11:09, 21 May 2009 by Badge (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

POPALL statement

Syntax: POPALL

Discussion: The POPALL statement clears all return addresses from the GOSUB stack. It is used to branch directly from a nested subroutine (at any level) to the main program.

Note: If the subroutine stack is empty, the POPALL statement has no effect (i.e., it does not result in an exception branch).

See POP.

Example:

 GOSUB 1000
.
500     PRINT (0) "CUSTOMER OVER CREDIT LIMIT."
.
1000    OPEN (1) "C1A",EXCP=9000
       READ (1,1000) EXCP=8000
       IF ARTOTAL > 0 THEN  2000
       .
       RETURN
 !
2000    FLAG1$ = "Y"
       IF ARTOTAL > CRLIMIT THEN POPALL AND GOTO 500
       .
       RETURN

In this example, the main section of the program directs control to subroutine label 1000. Within that subroutine, if a certain condition is met (namely if ARTOTAL is greater than 0), program control is directed to a nested subroutine at label 2000.

Within the nested subroutine, if a certain condition is met (in this case, ARTOTAL greater than CRLIMIT), all return addresses are popped from the subroutine stack and program control is transferred directly to statement 500 in the main section.

Personal tools