Advanced features / Programs |
The MAIN block is the starting point of the program.
MAIN [ define-statement | constant-statement | type-statement ] { [defer-statement] | fgl-statement | sql-statement } [...] END MAIN
When the runtime system executes a program, after some initialization, it gives control to the MAIN program block.
The MAIN block typically consists of a set of interruption handling instructions, runtime configuration options, database connection and a call to the main function of the program.
IMPORT cust_module MAIN DEFINE uname, upswd STRING DEFER INTERRUPT DEFER QUIT OPTIONS FIELD ORDER FORM, INPUT WRAP, HELP FILE "myhelp" CALL get_login() RETURNING uname, upswd WHENEVER ERROR CONTINUE CONNECT TO "stores" USER uname USING upswd WHENEVER ERROR STOP IF SQLCA.SQLCODE < 0 THEN DISPLAY "Error: Could not connect to database." EXIT PROGRAM 1 END IF CALL cust_module.customer_input() END MAIN