Академический Документы
Профессиональный Документы
Культура Документы
1. Introduction
2. Short, quick-and-dirty, general intro to x4GL
4GL Programs
Structure of a program
DATABASE section
GLOBALS section
Functions
MAIN block
DEFINE section
4GL Commands
1) Introduction
4GL programming language was born in Informix corp., about 15 years ago. Because
of that, and not to conflict with with 4GL as general programming concept (BASIC is
in principle also Fourth Generation Language, as opposed to C, that is Third
Generation Language), we should refer to basic 4GL syntax as I-4GL.
Today, even among Informix-distributed products, there is distinction among "classic"
I-4GL and D4GL (Informix name for 4Js 4gl compiler), that introduced number of
language enhancements. Then Informix implemented some of this enhancements back
to "classic" 4gl, and added some of it's own (v 7.3), that 4Js in turn implemented in
'Universal Compiler" V3 (this is actual name for 4Js product that Informix distributes
under the name "D4GL" - Dynamic 4GL.)
function/report/main block
.
.
.
.
function/report/main block
DATABASE section
This section is optional and is of the format :
DATABASE database-name
The database name is actually the DATA SOURCE NAME (DSN) from the ODBC
drivers.
GLOBALS section
This optional section allows you to define variables which are accessible to all
modules. There is normally a single file (typically called 'globals.4gl') where variables
are defined. All other modules which need these variables then include that file using
the a global statement .
eg.
globals.4gl
GLOBALS
DEFINE a INTEGER
END GLOBALS
module.4gl
GLOBALS "globals.4gl"
Note: In Aubit 4GL the any 'globals' module (containing the GLOBALS / END
GLOBALS) must be compiled first.
Functions
A function in 4GL is a set of commands which are executed when called from another
block of code. A function can accepts parameters and can return values.
A function is defined :
FUNCTION function-name ( parameter-list )
define-section
commands
END FUNCTION
Values are returned using the RETURN keyword:
RETURN value
MAIN block
Each program must contain a main section - it is the starting point in any program.
MAIN
define-section
commands
END MAIN
DEFINE section
This optional section allows you to define variables which may be used subsequently:
In its simplest form
DEFINE variable_names datatype
or
DEFINE CONSTANT constant_name "Value"
DEFINE CONSTANT constant_name Number-Value
More than one variable can be defined as any type in the same statement by separating
the names with a comma:
DEFINE a,b,c INTEGER
Available datatypes are :
SMALLINT (2 byte integer)
INTEGER (4 byte integer)
CHAR (Single character 'string')
IF num_vars<=num_elems THEN
LET lv_arr[num_vars]=1
END IF
4GL Commands
(syntax and documentation in Informix manuals)
CALL
CASE
CLEAR
CLOSE
CODE
CONSTRUCT
CONTINUE
CREATE
CURRENT WINDOW
DECLARE
DISPLAY
DROPS
ERROR
EXECUTE
EXIT PROGRAM
EXT
FINISH
FOR
FOREACH
GOTO
HIDE
HIDE OPTION
IF
INIT
INPUT
LABEL
LET
LOAD
LOCATE
MENU
MESSAGE
MOVE
NEXT FIELD
NEXT OPTION
OPEN
OPENS
OPTIONS
OUTPUT
PAUSE SCREEN
PREPARE
PROMPT
REPORT
RETURN
RUN
SET
SET DATABASE
SHOW
SHOW OPTION
SLEEP
SQL
SQLCODE
START
START RPC
STOP RPC
UNLOAD
WHENEVER
WHILE
DEFER
SYNTAX
DEFER INTERRUPT
...etc...