A simple BDL program

This simple example displays a text message to the screen, illustrating the structure of a BDL program.

Genero BDL source code is written as text in a source module (a file with an extension of .4gl). Because Genero BDL is a structured programming language as well as a 4th generation language, executable statements can appear only within logical sections of the source code called program blocks. This can be the MAIN statement, a FUNCTION statement, or a REPORT statement. (Reports are discussed in Chapter 9.)

Execution of any program begins with the special, required program block MAIN, delimited by the keywords MAIN and END MAIN. The source module that contains MAIN is called the main module.

The FUNCTION statement is a unit of executable code, delimited by FUNCTION and END FUNCTION, that can be called by name. In a small program, you can write all the functions used in the program in a single file. As programs grow larger, you will usually want to group related functions into separate files, or source modules. Functions are available on a global basis. In other words, you can reference any function in any source module of your program.

Although the language keywords in this example and throughout the tutorial are in all-capitals, this is just a convention used in these documents. You may write keywords in any combination of capitals and lowercase you prefer.

You can begin a comment that terminates at the end of the current line with a pair of minus signs (--) or #. Curly braces {} can be used to delimit comments that occupy multiple lines.

The following example is a small but complete Genero BDL program named simple.4gl.

01 -- simple.4gl
02
03 MAIN
04     CALL sayIt()
05 END MAIN
06
07 FUNCTION sayIt()
08    DISPLAY "Hello, world!"
09 END FUNCTION
Note: