Problem:
Using SOURCEFORMAT"FREE", getting syntax errors during compilation, for example:
--------------------------------------------------------------
*-- File msbilling.scb, Line 2016 -- HOST CODE
* 301-S ( 34)**
** Unrecognized verb
* 641-S********************* ( 35)**
** '.' missing following procedure name declaration, or unrecognized verb
--------------------------------------------------------------
MOVE "select ARTICLE_NBR, UNIT_COST, UNITS, UNIT_FET from MST
*1004-E****************************************************************( 37)**
** Continuation character expected. End of literal assumed.
- "07DPURC where DOCUMENT_NBR=" TO IILDAT2(1:82)
* 83-S ( 37)**
** Reserved word missing - TO expected.
--------------------------------------------------------------
The syntax errors are caused by the compiler directive SOURCEFORMAT"FREE" conflicting with two aspects of the source code:
1) comments that begin with an asterisk "*" in column 7, and
2) alphanumeric literals that use continuation character "-" in column 7.
Both the above are normal COBOL syntax when SOURCEFORMAT"FREE" is not turned on. The following explanation is from the Server Express documentation:
Free format COBOL is selected using the SOURCEFORMAT"FREE"
directive.
The first six characters are considered part of the normal
source line and may contain COBOL source code. Column 1
takes the role of the indicator area as follows:
* comment line
/ comment line starting on a new page in the listing file
D or d followed by space, debugging line
$ special line (for example, directive, conditional
compilation)
any other character normal source line
There are no continuation lines. Continuation of
alphanumeric literals is achieved through concatenation (for
example, "A" & "B").
Resolution:
The SOURCEFORMAT directive can be switched back and forth between "free" and "fixed" at any place within the source code by using the $set statement. Consider the program "j.cbl" attached to this Knowledgebase article. It is a complete program (not a fragment). It shows correct syntax, for comments and literal continuations, for both "free" and "fixed" format.
If the source code you are compiling contains a mixture of "free" and "fixed" format, here are a couple of strategies to fix the syntax errors:
1) Insert the $set statement at appropriate points in the code to switch back and forth between "free" and "fixed".
2) For large sections of code that include "fixed"-style comments and literal continuations, modify all the code to be properly "fixed", that is, indent all of it 8 spaces that isn't already indented.
If indenting 8 spaces pushes some of it past the right margin, which means beyond column 72, then use sourceformat"variable", which relaxes the right margin 72 restriction. Look up the SOURCEFORMAT compiler directive in the Server Express documentation for more information.