Академический Документы
Профессиональный Документы
Культура Документы
3
Informix 4GL The Programmer’s
Environment
Objectives
At the end of this module, you will be able to:
Navigate through the Informix 4GL Programmer’s Environment menu
Choose the appropriate menu option for a given task
Use the alternative command-line options to create programs
i4gl
r4gl
There are two ways to enter the Programmer's Environment. The method you use
depends on which type of Informix 4GL you have: 4GL Rapid Development
System or the C Compiler Version.
Informix 4GL C Compiler Version
To access the menu system for the Informix 4GL C Compiler Version, enter the
following at the system prompt:
i4gl
This will take you into the main menu, as shown on the next page.
Informix 4GL Rapid Development System
To access the menu system for the Informix 4GL Rapid Development System, enter
the following at the system prompt:
r4gl
This will also take you into the main menu.
Differences in the Menus
The following pages describe the menu environment of Informix 4GL. There are a
few differences between the Informix 4GL Rapid Development System and the
Informix 4GL C Compiler Version. These differences will be pointed out as you go
through this module.
At the top menu level of Informix 4GL, there are five options:
Module Takes you to the Module menu of an Informix 4GL
program module.
Form Takes you to the Form menu for a screen form.
Program Allows you to specify the components of a multi-module
program.
Query-language Allows you to use SQL interactively.
Exit Returns you to the operating system.
Note You must have purchased the Informix-SQL product in order for the
Query-language option to work.
The MODULE menu is used to create all the modules that will be needed for your
program. The options available are:
Modify Allows you to make changes to an existing module. If you
select this option, you will be asked to choose a module
from a given list and will then be placed into an editor.
When you are finished editing the module, you will go
through the compilation menus.
New Asks you to assign a name for a module, and then places
you in your editor. When you have finished writing your
new module, you will go through the compilation menus.
Compile Asks you to choose a file and then takes you through the
compilation menus.
Program_Compile Is the same as the Compile option of the PROGRAM
menu. It permits you to compile and link modules, as
described in the program specification database.
Run Presents a list of executable programs.
Debug allows you to choose a runable module to execute through
the Informix 4GL Interactive Debugger.
The FORM menu is used to create forms that can be displayed to the user. The
options available are described below:
Modify Allows you to change the look and functionality of a
form.
Generate Creates a default form.
New Takes you into an empty file where you can create a form.
Compile Translates an English-like form specification into
something the computer can use.
Exit Returns to the Informix 4GL Menu.
Menu Sequence:
No Errors in Code
MODIFY MODULE: Compile Save-and-exit Discard-and-exit
First Compile the 4GL module specification.
COMPILE MODULE: Object Runable Exit
Second Create an object file (.4go suffix)
MODIFY MODULE: Compile Save-and-exit Discard-and-exit
Third Save the 4GL module and return to MODULE Menu.
Once you have created or changed a module, you will be taken through the
compilation menus. The compilation menus are used to compile your Informix
4GL code into either an executable program or a linkable module.
The First Menu
The first menu consists of three choices:
Compile Takes you to the second menu, as shown above.
Save-and-exit Saves the changes made during the last editing session,
but does not try to compile them.
Discard-and-exit Discards the changes made during the last editing session.
(This option does not delete your file, providing you have
saved it at least one time.)
The Second Menu
The second menu consists of three choices:
Object Should be selected when the module is part of a multiple
module program.
Runable Should be selected when the module is a self contained
program. (It must have at least a MAIN function.)
Exit returns you to the first menu.
Informix 4GL The Programmer’s Environment 3-7
The Third Menu
The third menu consists of two choices:
Correct Returns you to the editor and points out errors in your
code. Once you have made corrections, you are returned
to the first menu.
Exit Returns you to the first menu.
The PROGRAM menu is used to link all the modules together into one program.
The options available are described below:
Modify Allows you to modify the data in your program
specification. You are prompted for the name of the
program you wish to modify. The Programmer's
Environment then displays a screen and menu which is
used to update the information about the program.
New Allows you to create a new program specification which
contains the modules and libraries that make up the
desired application program.
Compile Performs the compilation and linking described by the
program specification, taking into account the time when
the files were last updated. (This is the same as
Program_Compile in the MODULE menu.)
Planned_Compile Taking into account the time of last change for the various
modules that make up your program, this option presents
a summary of the steps that will be executed if you select
Compile.
NEW PROGRAM>>
Enter the name you want to assign to the program, and press RETURN.
The illustration above shows the program screen for Informix 4GL RDS. This is
the screen that appears if you choose the New or Modify option from the
PROGRAM menu. The options available here are described below:
4GL Takes you into the 4gl Source list. This is where you enter
the names of the modules that make up your program and
their paths.
Globals Allows you to update the Global Source array. If changes
are made to this module, then all modules will be
recompiled since changes to globals can affect all other
modules.
Other Allows you to update the Other .4go and Other .4go Path.
This is where you specify the names and locations of
other Informix 4GL object files.
Program_Runner Allows you to specify the file name and path of the p-code
runner that you want to run your program. A custom
p-code runner is needed if you are going to call a C code
function from within your Informix 4GL application.
The illustration above shows the program screen for the Informix 4GL C Compiler
Version. This is the screen that appears if you choose the New or Modify option
from the PROGRAM menu. The options available here are described below:
4GL Takes you into the 4gl Source list. This is where you enter
the names of the modules that make up your program and
the path for those modules.
Other Allows you to update the three-column screen array with
headings Other Source, Ext, and Other Source Path. This
is where you place the file name and location of C, Cobol,
or other source or object code.
Libraries Permits you to add the names of up to 10 libraries that you
want linked with your program.
Compile_Options Lets you supply up to 10 command line options for the C
compiler, if desired.
Rename Allows you to change the name of your program. This
affects what your executable file will be called.
Exit Returns you to the PROGRAM menu.
The 4GL option is used to enter a list of modules that make up your program. The
4gl Source column of this form is actually an array of values (that is, more than
just the five that are visible). Enter all of the modules that make up your program.
As your program grows, you can come back to this screen and enter additional
modules.
Global Source with Rapid Development System
The Global Source field is only available with the Rapid Development System. You
can enter the name of a module that contains your GLOBALS function. If you make
a change to the file listed in the Global Source field, all other modules will be
automatically recompiled. This is due to the fact that changes to this module could
affect the other modules in your program.
If you are using the Compiled Version, list the module that contains the GLOBALS
function in the 4gl Source array.
Working at
the Command Compiled Version: RDS:
Line c4gl fglpc
Using a
.SUFFIXES: .4gl .o .per .frm .c
Makefile .4gl.o :
/usr/informix/bin/c4gl -c $*.0 $<
.per.frm :
form4gl $*
.c.o :
As you have seen, the Programmer's Environment lets you list the files that are
part of an application. The advantage of this is that you can have the database keep
track of what to compile. However, there are limitations:
The Programmer's Environment puts all compiled files in the current directory
(that is, the directory from which you invoked the Programmer's
Environment). You may want to keep different source files and compiled files
in different directories.
The Programmer's Environment only sees form files in the current directory.
You may want to put form files in a separate directory.
You cannot customize the commands that the Programmer's Environment uses
to compile. So if you want to use a special option or change file names, you
have to use the compile command directly. This is true for forms and for code.
These limitations can become more problematic in large applications. They can all
be resolved, however, if you work from the command line and use the make utility.
The -o option allows you to specify the name of the output file. If you omit this
-o option, the default output file is named a.out.
The c4gl command performs the necessary processing steps to invoke the
preprocessors, link the object files, and produce an executable 4GL program.
When the compilation completes successfully, c4gl automatically removes the
intermediate files with extensions .c, .ec, and .4ec, which are generated during
the phases of compilation.
3. If errors occur, an error file will be created, filename.err. Correct any errors in
the source module using the text editor, and re-compile.
The separate object files can be linked with the module that contains the MAIN
program block at a later time, to produce an executable C program:
c4gl file1.4gl file2.o file3.o -o appl.4ge
There are additional options that can be specified for the c4gl command to customize
the processing. For a complete description of these options see the Informix 4GL
Reference Manual.
Informix 4GL Rapid Development System can also be used from the command
line to create programs. The p-code that is created by the compiler can be executed
using the p-code runner.
A single module program
1. Create a 4GL source code module using vi, or another text editor. Name the file
filename.4gl.
2. Compile the program to p-code by entering the following at the command line:
fglpc filename.4gl
The fglpc command compiles your source code and produces a file containing
tables of information and blocks of p-code, with the file name filename.4go.
3. If errors occur, an error file will be created, filename.err. Correct any errors in
the source module using the text editor, and re-compile.
In order to execute the resulting .4go p-code file, the p-code runner must be used to
interpret the code:
fglgo filename.4go
Before the program can be run the p-code modules must be combined into a single
file:
cat file1.4go file2.4go > myprog.4gi
Then the p-code runner (or the Debugger, if available) can be used to execute the p-
code:
fglgo myprog.4gi
If you do not specify the file extension, fglgo looks first for the filename with a .4gi
extension, and then for the filename with a .4go extension.
See the Informix 4GL Reference Manual for additional options to the fglpc and fglgo
commands.
Examples:
make
make target
The make utility is a system utility which generates and executes commands. Many
development shops use the make utility to keep track of source files that have
changed, and to re-compile when necessary.
The make utility uses a description file (command file), known as the makefile or
Makefile, and some general templates to determine the dependencies between the
files. Before linking the object files, make checks to see if each of the prerequisites
are up to date. In addition to the description file, make derives necessary
information from the last-modified time of files as recorded in the file system.
To invoke make, you can issue one of the following commands:
make
make target
In the first option, the utility will make the first target it finds in the makefile. In the
second option, you specify the target to make after the make command. More than
one target can be specified on the command line.
FORM = formname.per
Enter your
filenames here. PROG_NAME = application.4ge
COBJS = $(4GL:.4gl=.o)
POBJS = $(4GL:.4gl=.4go)
CFORM = $(FORM:.per=.frm)
RDS_NAME= $(PROG_NAME:.4ge=.4gi)
CCODE: $(COBJS)
c4gl -o $(PROG_NAME) $(COBJS)
@- echo "Finished compiling ccode..."
PCODE: $(POBJS)
cat $(POBJS) > $(RDS_NAME)
@- echo "Finished compiling pcode..."
FORM: $(CFORM)
@- echo "Finished compiling forms..."
.4gl.4go:
fglpc $*.4gl
.4gl.o:
c4gl -c $*.4gl
.per.frm:
form4gl -s $*.per
Note The indented lines of makefiles must have tab characters. Using blank spaces will
prevent the makefile from working.
Use the PROGRAM menu to link the modules that make up the demonstration
application.
Create the Program Database
Choose New from the PROGRAM menu. You may need to answer Yes when asked
to create a program database (syspgm4gl).
Name your program cust# where # represents your student login number (e.g.,
cust1).
List the Modules
You will now be placed in the PROGRAM screen. Enter the names of the modules
that make up the program cust#. These modules are listed in the slide above (all of
the modules).
Rapid Development System: List all modules, except d4_globals, in the 4gl
Source field. The d4_globals module should be placed in the Global Source
field.
C Compiler Version: List all modules, including d4_globals, in the 4gl Source
field.
Leave the Program Screen
When you have entered all of the modules, press the ESC key, and then choose Exit.
MODIFY MODULE>>
USE-EDITOR>>vi
CHOOSE DATABASE>>
NEW FORM>>
CHOOSE TABLE>>
MODIFY FORM>>
USE-EDITOR>>vi
Extension Description
.4gl Informix 4GL Source module
.4ge C Compiled Version executable
.o C Compiled Version object
.4go RDS Version object
.4gi RDS Version program
.per Form File Source
.frm Form File Compiled
.msg Message file source
.ex or .iem Message File Compiled
File Extensions
.4gl Informix 4GL Source module
.4ge C Compiled Version executable
.o C Compiled Version object
.4go RDS Version object
.4gi RDS Version program
.per Form File Source
.frm Form File Compiled
.msg Message File Source
.ex or .iem Message File Compiled
The extensions .4gl, .4ge, .4go, .4gi, are Informix naming conventions which are
enforced only when you are using the Programmer’s Environment. The extensions
.msg, .ex, and .iem are simply naming conventions also. Your company may have
different naming standards.