|
<< Click to Display Table of Contents >> Module organization of Gekko program files |
![]() ![]()
|
Gekko program files can be nested, that is, a Gekko program file calling another program file, which in turn calls a third program file, etc. It can be an advantage to separate large automated runs in several program files, where the individual steps are separated into modules. For example, program.gcm can contain several separate steps:
Program.gcm
run step1.gcm; // Reads input data |
There are several advantages to modularity. For example, it makes it possible to reuse a group of statements. It can also provide a clearer structure in more complex tasks, which makes the programs easier to write, troubleshoot and reuse.
However, complications can occur, especially when calling Gekko program files from other program files. Circular calls should obviously be avoided, for instance where file1.gcm calls file2.gcm, which in turn calls file1.gcm.
The following statements are particularly useful in modular/nested program files:
Can be used for interactive user input. |
|
Stops the execution of statements, writes the text to the output window, and waits for the user to press [Enter]. Example: pause 'Click [Enter] to continue';. |
|
Example: tell 'The calculations are now finished';. |
|
Returns from the currently executing program file, and returns to its 'parent' (calling) program file. RETURN is also used for functions and procedures. |
|
Stops the run and ignores the rest of the cmd file. Also interrupts runs of nested files, in contrast to RETURN. |
Instead of using (nested) program files, it is also possible to use user-defined functions or procedures (more on this in a later section). These are defined first, and can be called subsequently. They can be called with arguments, providing ease of use and encapsulation.
When a larger Gekko session is running (for instance running a number of program files), you may use the menu item Utilities --> Run status... to see how Gekko is progressing (or double-click the yellow 'traffic light' at the bottom left of Gekko main window). In addition, you may track which data files are read and written by activating the menu item Options --> Program dependency tracking. When active, a Gekko session will conclude by showing which program files were run and which data files were read and written. This info can be practical for larger structures of Gekko program files.