END |
![]() ![]() ![]() |
The END statement terminates a program, subroutine or a block of statements conditioned by the THEN, ELSE, LOCKED or ON ERROR keywords.
Format
END
When used to terminate a program or subroutine, the END statement may not be followed by any further executable statements; only comments and blank lines are allowed. An END statement is not mandatory at the end of a program, subroutine or function but lack of an END will cause a warning message to be displayed as this may be symptomatic of a structural problem elsewhere in the program.
The compiler will generate a RETURN statement at the end of the program or subroutine which will be executed if there is no RETURN or other program flow control statement immediately prior to the END.
The END statement is also used to terminate a group of conditional statements. For details of the use of END in this way, see the description of the QMBasic statement to which the conditional element applies.
Example
READ REC FROM STOCK.FILE, ITEM THEN DISPLAY "Stock item " : ITEM GOSUB PROCESS.ITEM END
This program fragment reads a record from a file, displays its record id and calls an internal subroutine to process the record. The two indented statements are both conditioned so that they only occur if the read was successful. |