t3x.org / t3x / t3x-manual / 276.html
 
T3X - A Minimum Procedural Language
Version 8.1.5, Online Edition
Copyright(C) 1996-2004
Nils M Holm
 
Previous:
2.7.5 Branch Statements
TOC | Index | Back Next:
2.7.7 Local Symbols

2.7.6 Compound Statements

A compound statement (sometimes also called a statement block) is used to group a list of declarations and statements in order to form one single statement. Statement blocks are delimited by the keywords DO and END:

DO
    declarations
    statements
END

A compound statement may occur in any place where a simple (non-compound) statement is expected. In commands like

IF (expression) statement

a compound statement can be used to extend the scope of the conditional statement so that IF is applied to a group of statements rather than to a simple statement:

IF (a < '0' \/ a > '9') DO VAR b::3;
        t.write(T3X.SYSOUT, "Not a valid digit. Code=", 25);
        t.write(T3X.SYSOUT, str.format(b, "%X\N", [(a & 0xff)]),
                str.length(b));
        RETURN -1;
END

In this example, both t.write() messages and the RETURN statement will only be processed if the IF-condition applies. (The concept of sending messages will be explained in detail in the chapter about the T3X object model.) There is no terminating semicolon after a compound statement. The line

DO p(); q(); END ;

would be recognized as a compound statement containing the procedure calls P() and Q() and an empty statement consisting only of a single semicolon.

In T3X, compound statements are ordinary statements and they may occur at any place where a statement is expected. Even statements like

DO DO END DO END END

are perfectly valid. The use of compound statements in sequences becomes clear in the next sections where the allocation of local storage in compound statements is explained.

Previous:
2.7.5 Branch Statements
TOC | Index | Back Next:
2.7.7 Local Symbols