RUN Statement

<run statement>

──┬─ RUN ─────┬─ <object code file title> ─┬────────────────────────┬──►
  └─ EXECUTE ─┘                            └─ <run parameter list> ─┘
►─┬───────────────────────────────┬─┬────────────────────────┬─────────┤
  └─ [ ── <task identifier> ── ] ─┘ └─ <task equation list> ─┘

<run parameter list>

      ┌◄─────────────────── , ───────────────────┐
── ( ─┴─┬─ <real expression> ─┬────────────────┬─┴─ ) ─────────────────┤
        │                     └─ REFERENCE ────┤
        ├─ <integer expression> ─┬─────────────┤
        │                        └─ REFERENCE ─┤
        ├─ <Boolean expression> ─┬─────────────┤
        │                        └─ REFERENCE ─┤
        └─ <string expression> ─┬──────────────┤
                                └─ REFERENCE ──┘

Explanation

The RUN statement initiates a previously created object code file. If the object code file title specified is not an executable object code file, the job or processed subroutine is discontinued.

Parameter checking is done against the object code file, and any mismatches cause the job to be discontinued. By default, all parameters are passed by value. The keyword REFERENCE indicates that the parameter is passed by reference rather than by value.

Note: REFERENCE is valid only if the preceding expression is an identifier.

When a parameter has been passed by reference, the actual parameter is updated whenever the formal parameter is changed. If the WFL job that initiated the program inquires on the value of a passed-by-reference parameter while the program is running, the latest value is returned. The receiving program of a passed-by-reference string parameter should not resize the parameter smaller than 300 words (1800 characters.)

Strings consist of EBCDIC characters and are passed as arrays. If a string expression is passed by value, an extra NUL (48“00”) character is added to the end of the string to enable the object program to determine the length of the string. This string can be up to 1800 characters long. If a string identifier is passed by reference, a real array large enough to hold the maximum size of the string is passed with NUL characters padded to the end of the array. The contents of the array can be changed in the object program. If the task is initiated by a RUN statement, WFL updates the length of the string by locating the first NUL character in the array.

If the task is initiated by a PROCESS RUN, the length of the string cannot be changed by the processed task.

A task equation list can be given to override any task attribute assignments, file equations, and database equations set when the object code file was created. Refer to Task Equation and “Run-Time Overriding of Compiler Task Equation” under Local Data Specifications.

Note: Using the NAME task attribute as part of the RUN statement overrides the file name specified in <object code file title>.The following example runs OBJECT/Y:
RUN OBJECT/X; NAME = OBJECT/Y

Examples

The following are examples of simple RUN statements:

RUN X;
RUN A/B [T];
RUN A/C (1,I,FALSE,3.14,OCTAL ("123"), "HI THERE") [T1];
    FILE F(BLOCKSIZE=10, KIND=TAPE);
    FILE G(KIND=DISK);
RUN A/D (COUNT REFERENCE, TRUE, STR1 REFERENCE);
RUN A/E; TASKVALUE=I;

The following examples depict different methods of specifying early AXs in a RUN statement. The ability to supply an early AX command with a RUN statement is always available. Multiple AXs, however, will be passed to the program by the MCP only if the QUEUEDAX system option is set (SYSOPS QUEUEDAX SET).

If multiple early AXs are entered for a program while QUEUEDAX is RESET, then only the final AX is actually passed to the program.

The following job queues a 1-byte AX message, specify a priority of 70, and queues a 13‑byte AX message behind the first AX message. All three task assignments are for task T. When PROGA encounters an ACCEPT statement, it will accept “1” first, and then accept “MESSAGE THREE” when it encounters the next ACCEPT statement.

?BEGIN JOB EXAMPLE/EARLYAX;
TASK T (AX="1", PRIORITY=70, AX="MESSAGE THREE");
RUN PROGA[T];
?END JOB.

The following job queues a 1-byte AX message, specifies a priority of 70, and queues an 11‑byte AX message behind the first AX message. All three task assignments are for task PROGB. When PROGB encounters an ACCEPT statement, it will accept the “1” first, and then accept the “MESSAGE TWO” when it encounters the next ACCEPT statement.

?BEGIN JOB EARLYAX;
STRING S := "MESSAGE TWO";
RUN PROGB;AX="1";PRIORITY=70;AX=S;
?END JOB.

The following statement is the same as the first example, except that it is a PROCESS RUN statement:

PROCESS RUN PROGA[T];
Note: AX input relates to the next ACCEPT encountered in the stack, either by library code or the program's code. This can cause AX messages to be unintentionally routed to a library when they were intended for the client task.

Be careful when using the AX attribute with a task that will attach an interrupt to the ACCEPTEVENT. The ACCEPTEVENT will already be in the happened state before the task can possibly enable the interrupt. For further information, refer to the Task Management Programming Guide.

The following example shows the use of WFL-provided parameters for a program written in ALGOL:

?BEGIN JOB EXAMPLE/ALGOL;
  INTEGER I;
  STRING STR := "WFL STRING";
  COMPILE ALG WITH ALGOL LIBRARY;
ALGOL DATA CARD
 $ SET LEVEL 2
PROCEDURE D(WFLINTEGER, WFLSTRING, WFLBOOLEAN);
  INTEGER WFLINTEGER;
  ARRAY WFLSTRING[*];
  BOOLEAN WFLBOOLEAN;
BEGIN
  ARRAY A[0:49];
  WFLINTEGER := 20;
  REPLACE POINTER(A) BY "WFLSTRING = ",
                         POINTER(WFLSTRING) FOR 256 UNTIL=48"00",
                         48"00";
  DISPLAY (POINTER(A));
  REPLACE POINTER(WFLSTRING) BY "WFL STRING HAS BEEN CHANGED",
                                48"00";
END.
? % END OF COMPILER DATA
  RUN ALG (I REFERENCE, STR REFERENCE, TRUE);
  DISPLAY "I = "& STRING(I, *); % I = 20
  DISPLAY "STR = "& STR; % STR = "WFL STRING HAS BEEN CHANGED"
?END JOB.

The following example shows the use of WFL-provided parameters for a program written in COBOL74. Programs written in COBOL74 cannot specify Boolean parameters.

?BEGIN JOB EXAMPLE/COBOL74;
STRING STR := "WFL STRING";
COMPILE COBOL74/EXAMPLE WITH COBOL74 LIBRARY;
COBOL74 DATA CARD
100100IDENTIFICATION DIVISION.
100200ENVIRONMENT DIVISION.
100300DATA DIVISION.
100400WORKING-STORAGE SECTION.
10050077 WFLINTEGER BINARY PIC 9(11) RECEIVED BY REFERENCE.
10060001 WFLSTRING RECEIVED BY REFERENCE.
100700   03 MSG        PIC X(30).
10080001 CHARMESSAGE   PIC X(30).
100900PROCEDURE DIVISION USING WFLINTEGER, WFLSTRING.
101000P1.
101100   STRING WFLSTRING DELIMITED BY LOW-VALUE
101200          INTO CHARMESSAGE.
101300   DISPLAY "WFLSTRING = ", CHARMESSAGE.
101400   MOVE "WFL STRING HAS BEEN CHANGED" TO WFLSTRING.
101500   STOP RUN.
? % END OF COBOL74 DATA CARD
  RUN COBOL74/EXAMPLE (1234, STR REFERENCE);
  DISPLAY "STR = "& STR;
                 % STR = "WFL STRING HAS BEEN CHANGED "
?END JOB.

The following example shows the use of WFL-provided parameters for a program written in Pascal:

?BEGIN JOB EXAMPLE/PASCAL;
STRING STR := "WFL STRING";
BOOLEAN BOOL := TRUE;
COMPILE PASC WITH PASCAL LIBRARY;
PASCAL DATA CARD
PROGRAM p((VAR WFLInteger:INTEGER; VAR WFLString:WFLStringType;
           VAR WFLBoolean: BOOLEAN));
TYPE WFLStringType = RECORD str:PACKED ARRAY [1..30] OF CHAR;
                     END;
BEGIN
DISPLAY (CONCAT('WFLString = ', WFLString.str));
IF WFLBoolean THEN
    DISPLAY ('WFLBoolean = TRUE')
ELSE
    DISPLAY ('WFLBoolean = FALSE');
WFLString.str := CONCAT('WFL string has been changed', CHR(0));
WFLBoolean := FALSE;
END.
? % End of Pascal Data Card
  RUN PASC (23, STR REFERENCE, BOOL REFERENCE);
  DISPLAY "STR = " & STR;
                        % STR = "WFL STRING HAS BEEN CHANGED"
  IF BOOL THEN          % BOOL = FALSE
    DISPLAY "BOOL = TRUE"
  ELSE
    DISPLAY "BOOL = FALSE";
?END JOB.

The following example shows the use of WFL-provided parameters for a program written in NEWP:

?BEGIN JOB EXAMPLE/NEWP;
 INTEGER I := 10;
 BOOLEAN BOOL := FALSE;
 COMPILE NEWP/EXAMPLE WITH NEWP LIBRARY;
 NEWP DATA CARD
  $ SET LEVEL 2
 PROCEDURE P(WFLINTEGER, WFLSTRING, WFLBOOLEAN);
             INTEGER WFLINTEGER;
             ARRAY WFLSTRING[*];
             BOOLEAN WFLBOOLEAN;
 BEGIN
 ARRAY A[0:49];
   REPLACE POINTER(A) BY "WFLINTEGER = ",
                         WFLINTEGER FOR 10 DIGITS,
                         48"00";
   DISPLAY (POINTER(A));
   WFLINTEGER := 20;
 END.
? % END OF COMPILER DATA
   RUN NEWP/EXAMPLE (I REFERENCE, "ABCD", BOOL);
   DISPLAY "I = " & STRING(I, *); % I = 20
?END JOB.