Introduction to Program parts
A program part is a main logic part with one entry point. A program part defines the central logic in a runtime program.
Each Program part contains a main() function,
which represents the logic that runs at program start up. A program
can include other functions and can access functions that are outside
of the program. The function main() can invoke those
other functions. Any function can give control to other programs.
Program parts use stereotypes to specialize code for user interfaces. The BasicProgram is the only stereotype that is part of the core EGL package. A BasicProgram can access databases or files, perform calculations, and use most EGL statements. Some UI technologies offer additional stereotypes.
Many properties are available at the program level that affect code behavior. The properties that are available depend on UI and data access technologies.
Main versus called programs
main() function with no parameters. The
following example shows a called program: Program custProcessing1 type basicProgram (customerNum INT)
// required main() function
function main()
// get the correct customer name
// based on the customer number passed
customerName = getCustName(customerNum);
...
end
// another function
Function getCustName(customerNum INT) returns (CHAR(25))
...
end
end
program custProcessing1 type basicProgram (customerNum INT)
program custProcessing1 type basicProgram ()program custProcessing1 type basicProgramcustomerName CHAR(30)
...
call custProcessing1(customerName);program custProcessing1 type basicProgram (custName CHAR(80) inout)Because EGL passes a pointer to the customerName variable,
the custName variable has an actual length of only
30 characters. If you write to positions 31 - 80 of the custName variable,
which is legal in the program, you might overwrite random memory.
Note that the EGL debugger gives you a warning when such undefined
behavior is about to occur.
For more information about called programs, see Transfer of control across programs.