36 4gl Coding

What Should an INFORMIX-4GL Program Do?

An INFORMIX-4GL program should have a clear purpose and encompass only the tasks that are related to the tables being processed.

Basic Program Design

Directory Structure

  • Application Directory
    • Module Directory: ource and compiled screen forms (*.per and *.frm)
      • Program Directory: executable files (*.4gi or *.4ge)
        • Module File #1
    • Module Screens


Libraries are defined as repositories of functions or reports that perform a specific task.

Common Forms and Modules

Common forms and modules are defined as repositories of functions that perform a task that requires user and database interaction through query or input within a form or prompt.

Skeleton of an INFORMIX-4GL Program

[database <dbname>] --Required if the program interacts with a database
[globals] --Only one globals definition per program
 <global variable definition> 
 end globals ]
[globals "<file containing globals definitions>"]
 --Many global declarations per program
main --One, and only one, is required in a program
  <local variable definitions>
  <4GL statements>
  <function calls>
  <database interactions>
end main
[function <function name> (<parameters>) --A program may have many functions
    <local variable definitions>
    <4GL statements>
    <function calls>
    <database interactions>
    [return <return variables>]
 end function]
[report <report name> (<parameters>) --A program may have many reports
    <local variable definitions>
    <4GL statements>
    <report statements>
    <function calls>

end report]


The database statement has the following syntax:

[database <dbname> [exclusive]]

where dbname is a database name on your database server and exclusive opens the connection to the database in exclusive mode if there are no open connections and prevents any other user from connecting to the database.


The globals program block has two forms.

  • First Version:declares and defines the program variables that have global scope throughout the program.
   <global variable definition> 
 end globals ]
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.