The PERFORM verb is how you call a routine in COBOL. The basic syntax of a call is simple:
PERFORM MY-ROUTINE.
It is also what Cobol uses instead of a while loop:
PERFORM MY-ROUTINE UNTIL some-condition.
where the condition can be algebraic, such as EOF-FLAG = "Y" or REC-COUNT > 100; or it can be the peculiar Cobol thing known as an 88 level, a name for a condition.

It is also what Cobol uses instead of a for loop:

PERFORM MY-ROUTINE VARYING MY-VAR FROM 1 BY 1
                   UNTIL MY-VAR > 1000.
Ungainly, but not too bad. These for-loops can be nested within the one command, with up to three variables used:
PERFORM MY-ROUTINE VARYING MY-VAR2 FROM 1 BY 1
                   UNTIL MY-VAR2 > 1000
                   AFTER MY-VAR1 FROM 20 BY -2
                   UNTIL MY-VAR1 = 0.
Ooh, ugly.

Routines don't have parameters in Cobol. The variables used in the VARYING clause are ordinary variables defined in the DATA DIVISION; and they can be changed at any time inside the loop being called. This is a good way of screwing up a program, so committed Cobol programmers take advantage of it a lot.

If you're lucky your version of Cobol will support the command EXIT PERFORM, which neatly breaks from the routine or the current iteration. Otherwise, you have to perform a section which is divided up into paragraphs, and GO TO the final, empty paragraph.

You can perform both sections and paragraphs or any simultaneous combination thereof. The best spaghetti comes from mixing levels like this. Each PERFORM keeps track of its own place in the stack and what point should constitute an exit for it, but a well-placed GO TO to outside the currently performed region is always fun and enormously hard to debug, because it doesn't initially occur to you that anyone, not even a Cobol programmer, would be stupid enough to do it.

In COBOL85 apparently they have in-line performs, terminated with END-PERFORM. They probably look like this:

PERFORM
    statement-1
    statement-2
    ...
END-PERFORM.
But you're living in some kind of crazed fantasy world if you think that you as a Cobol programmer are going to see anything as technologically advanced as 1985 Cobol. Even if they can no longer get the licence for COBOL74 and have to upgrade to Cobol85, all the people who wrote the bulk of the system grew up on horn gramophones and those doglegged handles you start the front of a car with, so they won't have used any Cobol85 features. I don't think a serious description of Cobol needs to make reference to anything beyond 1974.

Per*form" (?), v. t. [imp. & p. p. Performed (?); p. pr. & vb. n. Performing.] [OE. performen, parfourmen, parfournen, OF. parfornir, parfournir, to finish, complete; OF. & F. par (see Par) + fournir to finish, complete. The word has been influenced by form; cf. L. performare to form thoroughly. See Furnish.]

1.

To carry through; to bring to completion; to achieve; to accomplish; to execute; to do.

I will cry unto God most high, unto God that performeth all things for me. Ps. lvii. 2.

Great force to perform what they did attempt. Sir P. Sidney.

2.

To discharge; to fulfill; to act up to; as, to perform a duty; to perform a promise or a vow.

To perform your father's will. Shak.

3.

To represent; to act; to play; as in drama.

Perform a part thou hast not done before. Shak.

Syn. -- To accomplish; do; act; transact; achieve; execute; discharge; fulfill; effect; complete; consummate. See Accomplish.

 

© Webster 1913.


Per*form", v. i.

To do, execute, or accomplish something; to acquit one's self in any business; esp., to represent sometimes by action; to act a part; to play on a musical instrument; as, the players perform poorly; the musician performs on the organ.

 

© Webster 1913.

Log in or register to write something here or to contact authors.