|Language:||English • 中文（简体）|
This query returns a Long value, indicating the state of the task. There are two conditions in which the regular task state is modified:
1) when the task is Locked
2) when the task is Interrupted
A task may be Locked in states 2, 4, and 10 if it is waiting for a system event to complete execution.
In this case, the value 256 (0x100) is added to the regular task state. This could occur when a task has three moves, one after the other. The interpreter is waiting to execute the second move until the first has completed.
If you enter a STOP command from the terminal, the task remains in the Running mode. Enter the IDLETASK command from the terminal and the task switches to a Stopped and Locked state. It is locked because it is waiting for the Proceed command to resume motion. A task is interrupted by either OnEvent or OnError. In this case, the value 512 (0x200) is added to the regular task state.
1: Running (TASK_RUNNING)
2: Stopped due to IDLETASK or after a STEPIN instruction (TASK_STOPPED)
4: Stopped due to runtime error (TASK_ERROR)
5: Terminated .
It can be seen momentary that state at: 1. Terminate program 2. Unload
7: Ready after LOAD (TASK_READY)
9: Task Kill Start . It's a first state of task termination procedure, after successful
termination state is internally changed to TASK_KILLED(10). In certain circumstances due to incomplete or delayed IO operation task can remain in this state and will require additional kill command.
10: Killed after KILLTASK OR END PROGRAM (TASK_KILLED)
If the task is interrupted by an event, the task state has the value 512 added to it. If the task is Locked, the task state has the value 256 added to it.
?TaskState (<task name> )
Version 3.6.20 and above
<task name> : String
Returned value: Long
Returned value: 1, 2, 4, 5, 7, 9, 10
Task or Terminal
Task must be loaded in memory
Common Shared Str1 as String
Str1 = “Task1.prg”