Skip to main content

Operator: __CURRENTTASK

The operator is an extension of the IEC 61131-3 standard.

At runtime, the operator provides information about the IEC task that is currently running.

Tip

The operator is supported only on target systems in which the target system setting memory-layout\max-stack-size is set to a value > 0.

The operator allows for access to a structure with two variables.

  • TaskIndex: Zero-based index that identifies the task

  • pTaskInfo: Detailed information about the currently running task

    Can be assigned to a POINTER TO Task_Info2 from the library CmpIecTask

The operator cannot be used in the declaration of a POU. The would result in an error message. If the current task cannot be determined, then the TaskIndex -1 and the pTaskInfo are zero.

Example 154. Example
//Declaration
VAR
        idx : INT;
        pInfo : POINTER TO Task_Info2;
END_VAR

//Program code

idx := __CURRENTTASK.TaskIndex;
pInfo := __CURRENTTASK.pTaskInfo;