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 file with an extension of
.4gl. Executable statements must appear within logical sections of the source
code called program blocks, such as the MAIN block and FUNCTION
blocks.
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.
External module usage must be declared with the IMPORT FGL statement, in the module
which is using symbols from that external module.
Source comment lines must start with a pair of minus signs (--) or with a single
#. Curly braces {} can be used to delimit comments that occupy
multiple lines.
1 -- simple.4gl
2
3 MAIN
4 CALL sayIt()
5 END MAIN
6
7 FUNCTION sayIt()
8 DISPLAY "Hello, world!"
9 END FUNCTION- Line
1simply lists the filename as a comment , which will be ignored by BDL. - Line
3indicates the start of theMAINprogram block. - Line
4: Within theMAINprogram block, theCALLstatement is used to invoke the function namedsayIt. Although no arguments are passed to the functionsayIt, the empty parentheses are required. Nothing is returned by the function. - Line
5defines the end of theMAINprogram block. When all the statements within the program block have been executed the program will terminate automatically. - Line
7indicates the start of the functionsayIt. - Line
8uses theDISPLAYstatement to display a text message, enclosed within double quotes, to the user. Because the program has not opened a window or form, the message is displayed on the command line. - Line
9indicates the end of the function. After the message is displayed, control in the program is returned to theMAINfunction, to line05, the line immediately following the statement invoking the function. As there are no additional statements to be executed (END MAINhas been reached), the program terminates.