Entering code

Previous chapterNext chapter Show allShow all    Hide allHide all

Doubleclicking the task in the Taskmanager opens it in the editing area. If the task is opened for the first time, the according VBS resp. JS file is created now.

Four procedures are automatically created:

Task_Init()

This procedure is automatically executed when starting the task.

Task_Main()

This procedure is either executed once (type once) or cyclically (type cyclic).

Task_Exit()

This procedure is automatically executed when stopping the task.

Task_Timer(lTimerId)

This procedure is executed cyclically, as long as the according time is running. The cycle time is defined as a parameter with the starting of the timer.

Generally speaking the PCE uses the same object model as VBA (see VBA Tutorials). When using VBA objects (except the object Task) multithreading is lost, because these objects only can be accessed from the main thread.

attention Attention

Not all funtions of the COM interface are multithread-able and therefore can only be used in a main tread context. If a different property than "in the main process" is set as PCE task, there must not be any access from the PCE to the main thread. In case there is an access to the COM interface nevertheless, this can lead to undefined system states, e.g. a Runtime freeze.

Of special importance are the collection Tasks and the object Task.