Skip to main content

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

  • May 24, 2017
  • 1 reply
  • 0 views

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.


#VisualCOBOL

1 reply

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.


#VisualCOBOL
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.