PERFORM

Depart from the normal program execution sequence to execute a particular paragraph or section and then return control to the statement immediately following the PERFORM statement. Optionally, send or receive arguments.
Restriction: This topic applies only when the AppMaster Builder AddPack has been installed, and applies only to Windows platforms.

Syntax: for Format 1

Perform a paragraph.

PERFORM paragraphname

Syntax: for Format 2

Perform a paragraph and pass arguments.

PERFORM paragraphname (actualargument1[[,]
... actualargument2[,] ... actualargumentN])
                      .
                      .
                      .
PARA  paragraphname ([+|-]formalargument1[[,]
      ... [+|-]formalargument2[,] ... [+|-]formalargumentN])

General Rules:

  1. When continuing a list of arguments onto one or more other lines, do not break an argument.
  2. The number of actual arguments must equal the number of formal argument names and be in the same order.

Parameters:

+|-

A plus (+) or minus (-) sign preceding a formalargument passes values between actual arguments and formal arguments, as follows:

 

With a plus sign (+), PERFORM passes the actualargument value to formalargument after the paragraph executes. The program does not return the formalargument value to actualargument.

 

With a minus sign (-), PERFORM passes the formalargument value to the actualargument after the paragraph executes.

 

If there is no plus or minus sign, the PERFORM passes the actualargument to its corresponding formalargument. After the paragraph executes, PERFORM passes the formalargument back to its corresponding actualargument.

actualargu-ment

Values you send to or receive from a formalargument in the paragraph; can be literals, identifiers, arithmetic expressions, variables, or index names.

formal-argument

Values you receive from or send to an actualargument in the PERFORM statement.

paragraph-name

Name of paragraph to perform.

Example:

PERFORM PARA-1( 'ABC', ABC-FLD, RESULT)
          .
          .
          .
PARA-1( +ARG1, +ARG2, -'Y')
Generates:
    MOVE 'ABC' TO ARG-1
    MOVE ABC-FLD TO ARG2
    PERFORM PARA-1 THRU .......
    MOVE 'Y' TO RESULT
Perform GET-SALARY (line 5010); pass the literal 20 to HOURS-WORKED and the value of HOURLY-RATE to PAY-RATE before calculating TOT-PAY (line 5020). After the GET-SALARY paragraph executes, pass the value of PAY-RATE to HOURLY-RATE and the value of TOT-PAY to WEEKLY-PAY.
000100  NTRY
   .
   .
   .
003010            IF CLASS = 'HALF-TIME'
003020                PERFORM GET-SALARY( 20,
003021                ... HOURLY-RATE, WEEKLY-PAY)
003030            ELSE
003040                PERFORM GET-SALARY( 40,
003041                ... HOURLY-RATE, WEEKLY-PAY)
003050            WEEKLY-PAY = WEEKLY-PAY * TAX
003060            COMPUTE MEDICAL-DEDUC =
003061            ... HOURLY-RATE * 1.50
   .
   .
   .
005010  PARA   GET-SALARY( +HOURS-WORKED,
005011        ... PAY-RATE,-TOT-PAY)
005020            TOT-PAY = HOURS-WORKED * PAY-RATE
   .