Thursday, March 09, 2006

Cobol : Conditional compile

This may apply only to Micro Focus.

Define a 78 level in Working Storage.

78 functionality value "yes".

Then use the $if .. $else .. $end construct,

$if functionality defined
* Conditional code xxx here.
$end

With this setup, xxx will be compiled. Now here's the trick. You would then expect that setting "functionality" to "no" would stop xxx from being compiled but no way!

You need to comment out the 78 line to achieve this.

You can also achieve this from the command line:

cob -C 'constant functionality "yes"' yyy.cbl

(Pay special attention to the use of ' and ").

Enjoy!

No comments: