Processing Data

The use of conditional statements implies that the job is going to be processing some data that can vary at run time. The following kinds of data can vary at run time:

  • WFL jobs that are stored on disk and initiated by a START statement can have parameter values passed to them.

  • During the course of a WFL job, the job can inspect the values of task attributes associated with tasks that were initiated in the job. Certain task attributes record task history. The WFL job can then make decisions about what to do next based on the history of the task that was initiated.

  • The job can also inspect the values of file attributes or test whether a file with a given title is resident, and then make decisions accordingly.

  • The job can include ACCEPT functions that will prompt you to supply input at run time and will cause the job to wait for your reply.

Examples

The following WFL job illustrates a use of the IF statement:

?BEGIN JOB WFLTEST;
  TASK COMPOK;
  DISPLAY "COMPILING NOW";
  COMPILE (SFL)OBJECT/SORT/PROC WITH ALGOL [COMPOK] LIBRARY;
    COMPILER FILE CARD(TITLE=SORT/PROC ON MYPACK);
  IF COMPOK IS COMPILEDOK THEN
    BEGIN
      DISPLAY "COMPILED SUCCESSFULLY";
      DISPLAY "RUNNING SORT/PROC";
      RUN (SFL)OBJECT/SORT/PROC;
    END
  ELSE
  DISPLAY "COMPILE NOT SUCCESSFUL --- WILL NOT RUN";
?END JOB.

This example first compiles a program and then inspects a task variable named COMPOK to see whether the compile was successful. If the compile was successful, the Boolean expression COMPOK IS COMPILEDOK evaluates to TRUE. In this case, the program that was compiled will be run. If the compile was not successful, then no attempt is made to run the program.

The DISPLAY statements in this example display messages at the ODT (and also at the CANDE terminal where the job was initiated).

The following example illustrates one use of the CASE statement:

?BEGIN JOB WFLTEST(STRING COMPTYPE);
  CASE COMPTYPE OF
    BEGIN
    ("SYNTAX"):     COMPILE (MAINT)OBJECT/ORD WITH COBOL74 SYNTAX;
                    COMPILER FILE CARD(TITLE=ORD,KIND=DISK);
    ("GO"):         COMPILE (MAINT)OBJECT/ORD WITH COBOL74 GO;
                    COMPILER FILE CARD(TITLE=ORD,KIND=DISK);
    ("LIBRARY"):    COMPILE (MAINT)OBJECT/ORD WITH COBOL74 LIBRARY;
                    COMPILER FILE CARD(TITLE=ORD,KIND=DISK);
    ("LIBRARY-GO"): COMPILE (MAINT)OBJECT/ORD WITH COBOL74 LIBRARY GO ;
                    COMPILER FILE CARD(TITLE=ORD,KIND=DISK);
    ELSE: DISPLAY "INCORRECT COMPILE TYPE ENTERED";
    END;
?END JOB.

In this example, a WFL job has been constructed that enables a user to compile a particular file in any of four possible ways according to the string parameter specified in the START statement.

The following table lists four START statements, each with a different string parameter specified and the results of each statement.

Statement

Result

START WFLTEST(“SYNTAX”)

Compiles the file ORD to check for syntax errors, but does not save the object code file.

START WFLTEST(“GO”)

Compiles and runs the file ORD, but does not save the object code file.

START WFLTEST(“LIBRARY”)

Compiles the file ORD, and saves the object code file as (MAINT)OBJECT/ORD.

START WFLTEST(“LIBRARY-GO”)

Compiles the file ORD and runs the object code file. The object code file is saved as (MAINT)OBJECT/ORD.

The following is an example of the DO statement:

?BEGIN JOB WFLTEST(INTEGER REPS);
  INTEGER INTREPS := 0;
  DO BEGIN
       RUN (WALLY)OBJECT/STOCK/PLAN;
       INTREPS := INTREPS + 1;
     END
  UNTIL INTREPS = REPS;
?END JOB.

This job runs the program (WALLY)OBJECT/STOCK/PLAN the number of times specified in the parameter of the START statement that initiated this job. For instance, START WFLTEST(7) runs the program (WALLY)OBJECT/STOCK/PLAN seven times.