Highlighted
Super Contributor.
Super Contributor.
516 views

Accidental stand-alone "PERFORM" doesn't generate compile error

Jump to solution

I've got Micro Focus Visual COBOL for Visual Studio 2010.   While working on a program, I accidentally compiled it while it had a stand-alone (incomplete) PERFORM command.  I was surprised to see that it didn't generate a compile error.

Is that an oversight in the compile logic, or does a stand-alone PERFORM actually do something?

Here's the code I accidentally compiled:

* Here's where we select our sample
IF NOT (M-SEX-CODE = 'F' OR 'M')
GO TO 2000-ENTRY.
****************************************************************
* Go create your user-selected numeric variable INM-NUMVAR
****************************************************************
PERFORM
****************************************************************
* Define the user-selected numeric variable INM-NUMVAR
* It may be a straight numeric variable from T-M (e.g., LOS DAYS)
* or a modified numeric variable (sent-length, 45-yrs life/death)
* or it may be a binary 0-1 (no-yes) var (pct burglars? no-yes)
*****************************************************************
* MOVE M-SERV-DAYS-PRSN-JAIL TO INM-NUMVAR.

MOVE M-SENT-LENGTH-DAYS TO INM-NUMVAR.

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert
The PERFORM doesn't really do anything, but it's not a compiler oversight.
It's legitimate to have an in-line perform statement without any optional phrases (VARYING, UNTIL, TIMES etc.), just to delimit a block of code. Thus:
PERFORM
DISPLAY "hello"
END-PERFORM
...is perfectly acceptable code.
We do allow automatic termination of in-line performs by '.' character (debatable whether this really should be allowed), so:
PERFORM
DISPLAY "hello".
...is also legal.

View solution in original post

1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert
The PERFORM doesn't really do anything, but it's not a compiler oversight.
It's legitimate to have an in-line perform statement without any optional phrases (VARYING, UNTIL, TIMES etc.), just to delimit a block of code. Thus:
PERFORM
DISPLAY "hello"
END-PERFORM
...is perfectly acceptable code.
We do allow automatic termination of in-line performs by '.' character (debatable whether this really should be allowed), so:
PERFORM
DISPLAY "hello".
...is also legal.

View solution in original post

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.