You declare a program part in an EGL file, which is described in EGL source format. When you write that file, do as follows:
The next example shows a called program part with two embedded functions, along with a stand-alone function and a stand-alone record part:
Program myProgram type basicProgram (employeeNum INT) { includeReferencedFunctions } // program-global variables employees record_ws; employeeName char(20); // a required embedded function Function main() // initialize employee names recd_init(); // get the correct employee name // based on the employeeNum passed employeeName = getEmployeeName(employeeNum); end // another embedded function Function recd_init() employees.name[1] = "Employee 1"; employees.name[2] = "Employee 2"; end end // stand-alone function Function getEmployeeName(employeeNum INT) returns (CHAR(20)) // local variable index BIN(4); index = 2; if (employeeNum > index) return("Error"); else return(employees.name[employeeNum]); end end // record part that acts as a typeDef for employees Record record_ws type basicRecord 10 name CHAR(20)[2]; end
For other details, see the topic for a particular type of program.
Related concepts
Parts
Program part
Related reference
Basic program in EGL source format
EGL source format
Function part in EGL source format
Text UI program in EGL source format
An example of a basic program is as follows:
program myCalledProgram type basicProgram (buttonPressed int, returnMessage char(25)) function main() returnMessage = ""; if (buttonPressed = 1) returnMessage = "Message1"; end if (buttonPressed = 2) returnMessage = "Message2"; end end end
The syntax diagram for a program part of type basicProgram is as follows:
If you do not set the alias property (as described later), the name of the generated program is either programPartName or, if you are generating COBOL, the first eight characters of programPartName.
For other rules, see Naming conventions.
For details, see Program properties.
If the caller's argument is a variable (not a constant or literal), any changes to the parameter change the area of memory available to the caller.
Each parameter is separated from the next by a comma. For other details, see Program parameters.
For details, see Program properties.
For details on writing a function, see Function part in EGL source format.
Related concepts
EGL projects, packages, and files
Overview of EGL properties and overrides
Parts
Program part
Syntax diagram
Related reference
EGL source format
Function part in EGL source format
Naming conventions
Program data other than parameters
Program parameters
Program part in EGL source format
Program part properties
Use declaration
The syntax diagram for a program part of type textUIProgram is as follows:
If you do not set the alias property (as described later), the name of the generated program is either programPartName or, if you are generating COBOL, the first eight characters of programPartName.
For other rules, see Naming conventions.
For details, see Program properties.
If the caller's argument is a variable (not a constant or literal), any changes to the parameter change the area of memory available to the caller.
Each parameter is separated from the next by a comma. For other details, see Program parameters.
For details, see Program properties.
For details on writing a function, see Function part in EGL source format.
An example of a Text UI program is as follows:
Program HelloWorld type textUIprogram {} use myFormgroup; myMessage char(25); function main() while (eventKey not pf3) myTextForm.msgField = " "; myTextForm.msgField=myMessage; converse myTextForm; if (eventKey is pf3) exit program; end if (eventKey is pf1) myMessage = "Hello Word"; end end end end
Related concepts
EGL projects, packages, and files
Overview of EGL properties and overrides
Parts
Program part
Segmentation in text applications
Syntax diagram
Related reference
EGL source format
Function part in EGL source format
Naming conventions
Program data other than parameters
Program parameters
Program part in EGL source format
Program part properties
Use declaration
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.