Encountering "155 Illegal command line" errors when compiling in Net Express

The Build window within a Net Express project shows the following:

Rebuilding D:\projdir\program.CBL
D:\projdir\program.CBL, (,) : 155 Illegal command line
Rebuild complete with errors 

This occurs when the directives line that is built is not correct.

Note, you may also receive the following error in place of the "155 Illegal command line" error, if the directive causing the failure was specified in a $SET statement within the program being compiled.

COBCH0053S Directive xxxxxxxx invalid or not allowed here: C:\myproj\X.CBL(2,18)

Also, if you have turned on the 'verbose' build option under Options/Project, an invalid directive located in any of the possible directive setting sources could also generate the following error instead of the 155 Illegal command line error.

So, as you can see, there are multiple cases in which you can receive either of these two errors due to an error in the directives that are set in the multiple places in which we allow them to be set. When the COBCH0053S error is directly caused by a $SET in the program being compiled (ie. You do not have the 'verbose' setting turned on), then locating the directive in error is straight forward and found within that program source (including copy files that may be associated with the source program). However, if you do have 'verbose' set or you receive the "155 Illegal command line", then you will need to refer to the information below to locate the location of the directive that is causing the problem.

Locating the directive causing the error

The directives that can be picked up for building the directives entry for the Net Express Build function can come from a number of sources. Because of this, the correction has to be a manual process of looking for all of these sources that you may have in effect on your system and examining the various directive definitions. The process sequence for checking these directive sources is as follows.

  1. Edit the program.CBL and check for any $SET entries followed by directives. 
    Check each directive against the help search to be sure they are correct and contain no semicolons.
  2. Look at the Project | Properties | Project directive settings in the white area on the right.
    Make sure you have only one semicolon after the last directive and check each directive in help that follows the standard directives listed below:
    %FILENAME
    COBIDY(%TARGETDIR) WB3 WB
    CSI ANIM EDITOR(MF2)
    ENSUITE(3); 
  3. Highlight the program.CBL in the left "Type of Build" window, right click and select build settings.
    Look at the directives contained in the white area of the Compile tab.
    Make sure you have only one semicolon after the last directive and check each directive in the help that follows the standard directives listed below:
    OBJ(%TARGETDIR\%BASENAME.obj);
    or 
    NOGNT INT(%TARGETDIR\%BASENAME.int); 
  4. If you have not found an error by this point, look for a COBOL.DIR file that is located within one of the directories listed in the environment COBDIR directories and/or within the same directory as the project. You could have a malformed directive in this file or a directives file by any name or extension that is referenced in any of the directive areas listed above that is combined with a "USE" or "DIR" directive (nested directives files, for example).  

Reference: Knowledge Base Document #17486