Structure of a program

The structure of a program consists of MAIN and FUNCTION blocks defined in several modules.

The program starts from the MAIN block. From the MAIN block, the code can invoke other blocks of instructions defined as callable routines with FUNCTION / END FUNCTION blocks. The language statements are executed by the runtime system in the order that they appear in the code:
MAIN
    CALL func1()
END MAIN

FUNCTION func1()
    DISPLAY "Hello from func1()!"
END FUNCTION
Some instructions can include other instructions. Such instructions are called compound statements. Every compound statement of the language supports the END statement keyword (where statement is the name of the compound statement), to mark the end of the compound statement construct within the source code module. Most compound statements also support the EXIT statement keywords, to transfer control of execution to the statement that follows the END statement keywords. By definition, every compound statement can contain at least one statement block, a group of one or more consecutive statements. In the syntax diagram of a compound statement, a statement block always includes this element:
MAIN
    INPUT BY NAME rec.*
        ...
        ON ACTION quit
            EXIT INPUT
    END INPUT
END MAIN