How Do I Skip the Initialization Code? (Magic xpa 3.x)

« Go Back


Created ByKnowledge Migration User
Approval Process StatusPublished

How Do I Skip the Initialization Code? (Magic xpa 3.x)

Whatever initialization process you have in the Main Program can be easily turned off by entering a condition in the condition column. Setting the Cnd: to No will prevent that code from executing.

Often, however, you will want to turn off the initialization only under certain circumstances, such as when you are testing. When you are testing programs, or using the Program Generator to look at files, the Main Program is automatically executed. This can slow things down a bit, and if you have some program that requires interaction in the Task Prefix (such as logging in to a timeclock), it can get time-consuming.

So, to conditionally prevent execution of code in these circumstances, you can use the RunMode() function. Runmode() returns:

  • -1 - When the Main Program of a project is executed for the first time on an enterprise server.

    When the project is closed and another is opened for the first context.

    When a project is opened for the first time under a multi-threaded background engine.

  • 0 - When a project is run under a full runtime engine, foreground runtime engine, background runtime engine, or background generator engine.

    If the function is evaluated in called programs and subtasks, RunMode returns 0.

  • 1 - When a project is activated from the Tools menu.

  • 2 - When a project is run under a Studio engine and the project is switched to Runtime mode.

  • 3 - When a project is run under a Studio engine and a program is executed directly from the Development mode.

So, for instance, to disable initialization code only during development, you would enter a condition of


and the code would only run in production.