The capabilities of the Program classifier are made available when you code a program, which has a single entry point: a function named main. The type is static; you do not create variables based on it.
A program has no parameters. It is started by a system command or by a transfer from another program. In the latter case, the program does not return control.
program MyProgram01 type BasicProgram {} function main() MyGradeList INT[3]{80, 90, 100}; MyAverage BIN(4,2); MyAverage = calculate(MyGradeList); SysLib.writeStdOut(MyAverage); end function calculate(myScore INT[]) returns (BIN (4,2)) numberOfScores, i, mySum INT; numberOfScores = myScore.getSize(); for (i from 1 to numberOfScores by 1) mySum = myScore[i] + mySum; end return (mySum/numberOfScores); end end
In the example, main declares variables, invokes a second function named calculate, and passes a list of three integers. The invoked function returns the average value, and main writes that value to the standard output.
The next table lists the stereotypes that are available for a Program type.
Stereotype | Purpose |
---|---|
BasicProgram (the default) | To define a program that might perform calculations, might access databases and files, and can use most EGL statements. A basic program does not accept real-time input from the user. |