Task Prefix (Magic xpa 4.x)
The Task Prefix is executed when the task initializes. It is a pure server-side handler and no client-side operations may be performed here (except in Offline tasks where it is a client-side operation).
Before the client task starts, the Magic xpa engine on the server opens the database tables, initializes the Virtual variables and, using the Range and Locate values, creates the initial Data View.
The client task hasn't started yet. Operations that are executed, execute on the server.
The client-side program and the data in the Data View are packaged into a small, encrypted XML package, which is sent over the Internet to the client machine.
It is important to remember that the execution of the Task Prefix, the initialization phase of the task, is executed on the server side as a whole. This means that in the initialization phase, any Call operation to a Rich Client task will be subjected to the following rule:
All Call operations will be executed at the designated time, but the Call task’s window is opened on the client side after completion of the Task Prefix. This means that all Call operations will take place after the other operations are executed.
Since Task Prefix is always server-side, you can't use client-side functions in these tasks. In this example, we are using the client-side CtrlGoTo() in Task Prefix, which is not allowed.
To provide this functionality, do the following:
-
Create a User event.
-
Create a handler for the User event.
-
Within the handler, enter the required client-side logic.
-
In the server-side handler, raise the User event with Wait=No.
This way, the handling of the User event that contains the client side logic will be done on the client side when idle.
To fix this problem, use a Raise Event in the server-side handler, with Wait=No. This way, the server-side handler will execute on the server. The event itself, however, will be executed on the client.
You need to be careful with Raise Events in Task Prefix. When an event is raised, the syntax checker cannot always determine where the event will be handled. We cover this more in Raise Event in Task Prefix.