Skip to main content

Problem:

A programmer uses the REMOVE compiler directive to take a reserved word out of action, and they do this generally (for all programs), but in one certain program, they would like to restore this reserved word.   How can this be done?

Resolution:

Use the ADDRSV compiler directive, and put it in a $SET statement in the source code of the program in question.   Even though the REMOVE directive is specified on the "cob" command line,  $SET statements override settings made elsewhere, so $SET ADDRSV will restore the reserved word.   Here is an example:

---------------------  driving shell script ---------------------------------

# compile the program with the reserved word SUBTRACT

# removed from being a reserved word (compilation should

# fail because the program uses SUBTRACT)

cob -C REMOVE\\"SUBTRACT\\" -v  addrsv_not_there.cbl

echo; echo;

# Now try a program where ADDRSV"SUBTRACT" is included

# in a $SET statement in the code; this should compile

# and run to completion

cob -C REMOVE\\"SUBTRACT\\" -v  addrsv_there.cbl

echo; echo;

cobrun addrsv_there

---------------- COBOL program "addrsv_not_there.cbl"  ---------

        01 data-item-1 pic 9(8) value 5.

        01 data-item-2 pic 9(8) value 10.

        SUBTRACT data-item-1 from data-item-2.

        EXHIBIT NAMED data-item-2.

---------------- COBOL program "addrsv_there.cbl"  ---------------

       $SET ADDRSV "SUBTRACT"

        01 data-item-1 pic 9(8) value 5.

        01 data-item-2 pic 9(8) value 10.

        SUBTRACT data-item-1 from data-item-2.

        EXHIBIT NAMED data-item-2.

Old KB# 7196