Using Task Variables

Explanation

Task variables are variables that can be associated with particular tasks. The means of defining them are provided in Task Variables. Task variables are used for two basic purposes: as a means of assigning task attributes or file equations to a task, and as a means of inquiring about the attributes of a task.

Any number of task variables can be declared and used in a job. Also, a particular task variable can be associated with more than one task in the course of a job. However, a task variable can only be attached to one task at any given time and cannot be reused until that task has terminated. Care should be taken when reassigning a task variable that was associated with an asynchronous task.

Examples

For example, the following statement is permissible:

RUN X [T]; 
INITIALIZE (T); 
COPY A AS B [T]; 

However, a run-time error results from the following:

PROCESS COMPILE X WITH ALGOL LIBRARY [T]; 
RUN Y [T]; 

If a task variable is not associated with an asynchronous task, the WFL compiler will allocate a task variable internally and associate it with the task.

Note that a run-time error will result if the PROCESS statement, which initiates tasks asynchronously, is executed in either of the following ways:

  • Repeatedly with the same task variable, while the previously processed task is still active.

  • In a loop (one that uses the DO or WHILE statement, for example) with no task variable, while the previously processed task is still active. The error occurs because the internal task variable is associated with more than one task at the same time.