The END statement terminates a program, subroutine or a block of statements conditioned by the THEN, ELSE, LOCKED or ON ERROR keywords.
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. For compatibility with other multivalue database products, the IMPLIED.STOP option of the $MODE compiler directive can be used to insert a STOP in place of a return in program, subroutine or function modules. Class modules always insert an implied RETURN regardless of the setting of this mode.
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.
READ REC FROM STOCK.FILE, ITEM THEN
DISPLAY "Stock item " : ITEM
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.