Informix 4GL is a fourth-generation programming language used to develop database applications that access Informix databases. It provides tools to create forms, program modules, and compile source code. Applications developed in earlier versions of 4GL can be run in the current version. 4GL allows procedural programming as well as nonprocedural access to databases, report generation, and user interaction through forms. The language is C-like but easier to use for developing database applications. Forms and reports are defined separately from program code and compiled for use in 4GL programs.
2. 11/01/16 @ 2013 IBM Corporation 2
Introduction
INFORMIX-4GL consists of a suite of tools that allow you
to efficiently produce complex interactive database
applications. Using the 4GL language, you can quickly
write sophisticated, portable, forms-driven, full-screen
applications for data entry, data lookup and display, and
report generation.
The 4GL development environment provides all the tools
necessary to design screen forms, construct and
manage program modules, and compile source
modules.
3. 11/01/16 @ 2013 IBM Corporation 3
Compatibility and Migration
You can easily use applications developed
with an earlier version of 4GL, such as
version 4.0 or 4.1, with this 6.0 version of
4GL. Also, if you have 4GL applications
written for the Windows environment, you can
compile and run the applications in the UNIX
environment also.
4. 11/01/16 @ 2013 IBM Corporation 4
What is 4GL?
4GL is a full-featured, general-purpose, fourth-generation
programming language with special facilities for producing
the following:
Database query and database management using the
Structured Query Language (SQL).
Reports from a database or other data.
Form- and menu-based multi-user applications.
These special features make 4GL especially well-suited to
developing large database applications.
5. What is Informix 4GL
Also known as I4GL, is a fourth- generation
application development language to create
custom database management applications
that access Informix databases.
6. 11/01/16 @ 2013 IBM Corporation 6
Interfaces of INFORMIX-4GL
INFORMIX-4GL have four primary interfaces to other
software:
Accessing a database through a database engine.
Communicating with users through a terminal.
Accessing sequential files through the host operating
system.
Generating reports that can then be sent to several
destinations.
7. 11/01/16 @ 2013 IBM Corporation 7
The INFORMIX-4GL Language
As a programming language, 4GL has several important
features:
It is a procedural language, with facilities for structured
programming.
It is a nonprocedural (“fourth-generation”) language with
regard to:
Database access
Reports
Form-based user interaction
It is C-like in design, but much easier to read, write, and
support.
8. 11/01/16 @ 2013 IBM Corporation 8
A Structured, Procedural Language
4GL is a general-purpose programming language for
creating structured programs, the way you might use
Pascal, C or COBOL. Like these languages, 4GL offer
statements you use to perform the following tasks:
Declare variables of different types
Calculate values and assign them into variables
Declare functions
Apply functions to data
Display the contents of variables on the screen
Also like other languages, 4GL has control statements you
use to define choices, loops, and statement blocks of code.
9. 11/01/16 @ 2013 IBM Corporation 9
Sample Program …
DEFINE given, product FLOAT , power INTEGER
MAIN
PROMPT "Enter a decimal number: " FOR given
LET product = given
DISPLAY " Exponent value"
FOR power = 2 TO 4
LET product = product * given
DISPLAY power, product
END FOR
SLEEP 5
END MAIN
10. 11/01/16 @ 2013 IBM Corporation 10
A Nonprocedural, Fourth-Generation Language
4GL is a nonprocedural, or “fourth generation” language
in three important areas:
Database access
Report generation
User interaction
In these areas you specify what is to be done, while
4GL (or the database engine) takes care of the actual
sequence of events.
11. 11/01/16 @ 2013 IBM Corporation 11
Database Access
FUNCTION update_rec(Rec1, Rec2)
DEFINE Rec1 FLOAT ,Rec2 CHAR(3)
UPDATE Record
SET unit1 = (1+Rec1)
WHERE unit2 = Rec2
RETURN unit3
END FUNCTION
12. 11/01/16 @ 2013 IBM Corporation 12
Program Source Files - Program Source Files
Each source file usually reflects a self-contained unit of
program logic; source files are sometimes called source
modules.
Execution of any program begins with a special, required
program block named MAIN. The source module that
contains MAIN is called the main module.
MAIN
CALL func()
END MAIN
FUNCTION func()
DISPLAY "Hello, world!"
END FUNCTION
13. 11/01/16 @ 2013 IBM Corporation 13
Continued ...
The Globals File – In 4GL programs, global
variables (variables available to more than
one source module) are declared in a globals
file and referenced through the GLOBALS
statement by each 4GL module that uses
them. For more information on local and
global variables.
14. 11/01/16 @ 2013 IBM Corporation 14
Steps to create .4ge binary from .4gl code
4gl command line compilation :
C4gl *.4gl –o *.4ge
*.4gl *.c *.o *.4ge
C compiler Native Compiler Linker
15. 11/01/16 @ 2013 IBM Corporation 15
Creating 4GL Reports
A report is a display of data. A well-designed report is arranged so
that the reader can easily pick out the important facts, such as
column totals or sub-totals. The data can be shown on a screen.
DataBase Report Driver Report Formatter Report
The Report Driver : The part of a program that generates the rows
of report data (also known as input records) is called the report
driver.
In 4GL, the actions of a report driver are as follows:
1. Use the START REPORT statement to initialize each report
to be produced.
2. Whenever a row of report data is available, use OUTPUT
TO REPORT to send it to the report formatter.
3. When the last row has been sent, use FINISH REPORT to
end the report.
16. 11/01/16 @ 2013 IBM Corporation 16
Forms
A form is a fixed arrangement of fields and labels, that is designed
to display the data items.
Defining a Form: Two steps are involved in creating a form:
1. Specify the contents of a form in a form specification file, an
ASCII file you create with any text editor capable of generating
ASCII text. Form specifications should be given the extension .per.
2. Compile the form specification. Compiled forms are usually
given the extension .frm.
The FORM4GL utility program is used to create .frm files. Once
compiled, a 4GL form can be used by any 4GL program.