To create proper and efficient programming structures, the commands must be placed in a logical, organized and optimized manner.
This logical and organized structure is based on simple and efficient programming control structures known as structured language. In this language class, the run flow is composed by well-defined instruction blocks. There are no commands that run unconditional deviations, such as the famous GO, GOTO and GOSUB, found in unstructured languages.
The control structures of AdvPL programming flow are grouped as follows:
It is the regular sequential flow of commands run. That is, one after the other. It is represented by most commands and explicitly by the command BEGIN SEQUENCE ... END.
It deviates the run flow according to a condition between two alternative ways. It is represented by the command IF ... ELSE ... ENDIF.
It repeats, in a controlled way, an instructions block in the run flow, while a determined condition is fulfilled. It is represented by the commands WHILE ... ENDDO and FOR ... NEXT.
It deviates the run flow according to several alternative ways. It is represented by the commands DO CASE ... CASE ... OTHERWISE ... ENDCASE and IF ... ELSEIF ... ELSE
All the control structures of AdvPL programming flow control are based on a single entry point and a single exit point. The instructions block to be run is added between them. This feature makes them efficient and simple for programming, maintenance and error debugging. You can elaborate any type of program with these structures.
The commands that make an instructions block, the ones between the inflow and outflow of the program flow control structure, are indented. Indenting means: writing the program structures after some blank spaces. Thus, the instructions block that is in one of AdvPL basic controls structures, and will be run inside it, is highlighted. This technique, that can be noted in all this documentation examples, has several benefits: it makes the programs clearer and simpler to be read and understood, helps the code maintenance and program errors debugging.
Further information can be found in Programming Good Practices.
The instructions block indentation technique in the programming flow control structures must be followed. This technique is a powerful tool for clear and concise program creation.