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.

The following example is a small but complete Genero BDL program named simple.4gl.
  1 -- simple.4gl
  2 
  3 MAIN
  4     CALL sayIt()
  5 END MAIN
  6 
  7 FUNCTION sayIt()
  8     DISPLAY "Hello, world!"
  9 END FUNCTION
Note:
  • Line 1 simply lists the filename as a comment , which will be ignored by BDL.
  • Line 3 indicates the start of the MAIN program block.
  • Line 4: Within the MAIN program block, the CALL statement is used to invoke the function named sayIt. Although no arguments are passed to the function sayIt, the empty parentheses are required. Nothing is returned by the function.
  • Line 5 defines the end of the MAIN program block. When all the statements within the program block have been executed the program will terminate automatically.
  • Line 7 indicates the start of the function sayIt .
  • Line 8 uses the DISPLAY statement 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 9 indicates the end of the function. After the message is displayed, control in the program is returned to the MAIN function, to line 05, the line immediately following the statement invoking the function. As there are no additional statements to be executed (END MAIN has been reached), the program terminates.