A function contains a series of EGL statements. Functions contain either the first executable code in a program or are called from another program. The function is not itself an EGL part (standalone functions are a special case; see Standalone Function part). For an overview of functions, see Introduction to functions.
Functions can include the following elements:
The name main() is reserved for the top-level function that runs first whenever you start or call a program. Every program part must contain a function named main() that has no parameters or return type.
When declaring parameters, specify whether each is used as input to the function (in), output from the function (out), or both (inOut). The inOut modifier is the default if you do not specify one. For more information, see Parameter modifiers.
EGL does not permit two functions to have the same signature (the combination of function name and number and type of parameters). Overloaded functions (same name but different signatures) are allowed. For more information, see Overloaded functions.
package com.CompanyB.CustomerPackage; program BalanceCheck type BasicProgram customer INT = 1; balance DECIMAL(7,2) = 0; function main() while (balance >= 0) balance = getCustomerBalance(customer); // returns -1 printBalance (balance); end // while end // main function getCustomerBalance (custNo INT in) returns (DECIMAL(7,2)) myCustomer CustomerRecord; // defined in library myCustomer.customerNumber = custNo; try get myCustomer; onException (CustomerNotFound) myCustomer.customerBalance = -1; // breaks loop end // try block return (myCustomer.customerBalance); end // function function printBalance (pBal DECIMAL(7,2) in) writeStdOut (strLib.formatNumber(pBal)); end // function end // program