Components and the Main Program (Magic xpa 3.x)

« Go Back


Created ByKnowledge Migration User
Approval Process StatusPublished

Components and the Main Program (Magic xpa 3.x)

The Main Program cannot be exported as part of a component, as this program cannot be executed by a Call operation.

When an object from another component is used - a program, a data source, or an event - it must first be preceded by the execution of the Main Program of that object’s project. This means that the first time an object from another component is used, the Task Prefix of its Main Program is executed, and its variables are initialized.

An exception to this rule is for components that are used immediately, which means that the component is loaded when the project is opened, and not when the component is actually used. For these components, the Main Program of the component is executed as soon as they are loaded.

The Task Execution Stack is not affected by the component’s Main Program execution. The program of the component is called by a parent program, and not its Main Program. The component’s Main Program is inserted in the Task Execution Stack just after the project’s Main Program and before all other programs.

When you execute the program of a Magic xpa component, the component application's Main Program takes part in the Magic xpa Runtime task tree. However, when you refer to a task's resources and information using functions such as Level, State or EOF, the component's Main Program is not counted in the task generation.
For example: if Task A calls Task B of a component, the function Level(1) will refer to task A and not to the component's Main Program.

When a project is terminated before the Task Suffix of the Main Program is executed, the Task Suffix is executed in the order opposite to the Task Prefix execution.