Main versus called programs
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 basicProgram
customerName 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.