Main Program Runtime Behavior (Magic xpa 3.x)
Unlike other programs, the Main Program does not have a Main Source. It can have Virtual variables that are initialized at the beginning of the project’s execution, and are used during execution of the entire project.
To allow you to open data sources as soon as the project opens, the data sources can be opened in the Main Program. Specific records can be read through the Link operation, and thus used throughout the project.
Records fetched by Link operations in the Main Program cannot be updated. If an update will be attempted it will be ignored, and the particular task update phase will not exist. Therefore, the Main Program does not execute any record locking or transaction managing commands. Table locking, however, will be available for the tables that are opened by the Main Program.
The Main Program executes as a Batch task whose record cycle is performed once. This behavior is not affected by Task Ending properties. As a project opens, the Main Program’s data sources open and its Task Prefix is then executed. The Main Program’s Virtual variables are then initialized and its link records read.
The Main Program’s Task Suffix is executed just before a project ends, when the project is terminated. The Main Program’s data sources will also close.
The Main Program can have regular subtasks, executed as a regular task. These subtasks can have a Main Source and function like regular tasks. However, their variables are not global variables. Only the Main Program’s root task variables are global.
In the Main program, like all programs, you cannot recompute variables from parent tasks that are updated from subtasks.
The Main Program cannot be called explicitly through a Call Program operation. If the Call operation is a Call Expression, and the expression in runtime evaluates to 1, an error message appears, and the Call operation will not be executed.
When the End Condition of the Main Program evaluates to True, the whole project will stop running.