Structured Programming
en-938872/2 1 - 3
1
The system provides the possibility of programming structured branches and loops,
making the programmes easier to read and simplifying the programming of complex
part programmes.
The programming tools described in this chapter are used to create subroutines
called by G functions (see Chapter 5).
1.1 General
A structured sequence always begins and ends with keywords.
It begins with one of the following keywords:
IF
REPEAT
WHILE
FOR
It ends with:
ENDI for IF
UNTIL for REPEAT
ENDW for WHILE
ENDF for FOR
The word ELSE can be interposed between the words IF and ENDI.
1.1.1 Commands Used in Structured Sequences
- Conditional execution of instructions: IF, THEN, ELSE, ENDI
- Repeat until loops: REPEAT, UNTIL
- While loops: WHILE, DO, ENDW
- Loops with control variables: FOR, TO, DOWNTO, BY, DO, ENDF
- Exit from a loop: EXIT
1.1.2 General Syntax Rules
The words IF, REPEAT, WHILE, FOR, ENDI, UNTIL, ENDW and ENDF must be the
first words in a block (no sequence number).
The words IF, REPEAT, THEN, ELSE, UNTIL, WHILE, DO and DOWNTO must
always be followed by a space, e.g.:
WHILEL0 <3 is not recognised by the system. The required syntax is WHILE L0 <3.
The words DO and THEN must immediately follow the condition. Alternately, if these
two words are not located on the same line as the words IF, WHILE and FOR, they
must be the first words on the next line.