Task Statement

Performs an unconditional branch (out of the normal program sequence) to the specified Task or Test.

Syntax

Task [EndEvents] task-specifier [ Uut lUutIndex ]

Comments

The Task statement is like a jump. It does not return to the statement following the Task statement after the task is completed. ATEasy executes tasks in a sequential order by default, so if you jump to Task 3, Task 4 will be called after that. When running from the test executive the next task after Task 3 is one in the tree view that is checked (selected for run).

You may choose to place some code in OnEndTask that will call the next task after the current task is completed. For example, in OnEndTask you can check the Task.Id or Task.Number or Task.Index to figure out what task was completed, you can also check Task.Status or check some global boolean variables or some number that will tell you what is the next task to execute. (Task.Id and Test.Id are unique in the application.)

The task-specifier can be an object or string expression, or a list of integer expressions. If task-specifier is an object expression, it should be the Task or Test object for any Task or Test in the current program. If task-specifier is a string expression, it should be the Id of any Task or Test in the current program.

If task-specifier is a list integer expressions separated by commas, then these numbers are directions on how to walk the tree of Tasks and Tests to get to the desired Task or Test. For example, the statement

Task 2, 4

specifies that going to the 2nd top-level Task, then to its fourth sub-task/test, Task or Test 2.4.  Note that the integer numbers are 1-based Task/Test numbers.

If task-specifier is a single integer expression with invalid value such as -1, 0, or 99 (where no Task 99 exists), the program will be terminated.

If task-specifier includes invalid value 0, for example

Task 5, 0

this statement will jump to first test of Task 6.

Unless the EndEvents optional keyword is specified, the OnEndTest and OnEndTask events are not triggered for the current test and task which are being terminated, but the OnInitTask (if starting a test in a different task) and OnInitTest events are triggered before starting the new test. When the Task statement is called within the OnInitTest, OnInitTask, or any other event, and if the EndEvents is specified, then the end events, OnEndTest, OnEndTask are called before jumping to the new task or test.

The statement generates a run-time error if task-specifier does not refer to a valid Task (invalid expression, for example 9.9), if a program is not being run, or if the program is being run in a special mode (such as Loop Test or Loop Task).

The optional keyword [ Uut lUutIndex] (introduced in ATEasy v8) specifies the UUT index that should be used. Omitting the clause will use the current UUT (default). The Uut clause sets the specified UUT index number (see App.UutIndex) as pending jump to the specified Task. That UUT must be running in sequential mode in order to work. When ATEasy switches to the specified UUT, the jump to the specified Task will be done.

 Example

! go to the last top level task ( or test )

Task EndEvents Program.Tests(Program.TestsCount-1)

! go to the power supply task

Task EndEvents "PowerSupply"

! terminate the current program

Task EndEvents -1

! go to task or test specified by number list -- see comments above for detailed explanation

Task EndEvents 2, 4

! go to task or test specified by number list in the third UUT running

Task EndEvents 2, 4 Uut 2

 

See Also

About Module Events, Initialization Events, End Events, GetProgramTasks, GetTaskNum, GetTaskTests, GetTestNum, SetProfileNum, Test Statement,  Task Variable, Test Variable, App.UutIndex