General structure of an Xbase++ program Foundation
This section shows a simple programming example illustrating the structure elements of an Xbase++ program. It begins with the declaration of a procedure having the identifier MAIN. This identifier is used for the main or startup routine of a program (meaning each Xbase++ program starts with MAIN). Within MAIN, a menu is programmed to allow the user to make a selection on the screen.
When the user has made a selection from the program, the program branches using a DO CASE control structure which calls various user defined functions and procedures.
The program code of the user-defined functions and procedures in the example merely displays a character string. The example primarily serves as an overview of structure and syntax elements of an Xbase++ program.
The example program demonstrates various conventions for how to write and arrange program code for clarity. Keywords for declarations, statements and commands are written in uppercase. Identifiers are shown in mixed case within the program code.
The beginning of user-defined functions and procedures is marked within the program code using comments. When using inline comments, it has proven effective to have the comments always begin in the same column, if possible. A well documented program is divided with program code on the left side and comments on the right side.
Following statements that introduce control structures, the program code is indented a specific number of blank spaces. As soon as the control structure ends via the corresponding termination statement, the indent ends and all subsequent lines begin at the previous column. Not only is the readability of the program improved, but nested statements can be easily tested for correct syntax by simply reading the code.
When program code from several programers is being used, blank space should always be used for indentation instead of the horizontal tab. A blank space is formatted the same way by all editors, while the tab can be formatted in different ways by different editors. Indenting is supposed to improve the readability of a program, but using tabs can have the opposite effect.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.