Conditional Compiles? 
Author Message
 Conditional Compiles?

I use MF Cobol as a workbench, then upload to MVS for production-ready
implementation.

One thing I like about C preprocessing is the IFDEF; getting debug code in the
source is very, very nifty and I'd really like to emulate (or enable) this for
COBOL.

Fully-forming the question: how can I accomplish debug (conditional) compiles
for MicroFocus COBOL (v4)?  

-Remo



Sun, 31 Jan 1999 03:00:00 GMT  
 Conditional Compiles?

Quote:

> I use MF Cobol as a workbench, then upload to MVS for production-ready
> implementation.

> One thing I like about C preprocessing is the IFDEF; getting debug code in the
> source is very, very nifty and I'd really like to emulate (or enable) this for
> COBOL.

> Fully-forming the question: how can I accomplish debug (conditional) compiles
> for MicroFocus COBOL (v4)?

Hi.
The following will achieve this. Note that the dollar signs are in column 7.

      *
      * These constants define the sort of OS this program can
      * adapt to at compilation time ....
      *
       78 OS-UNIX VALUE 1.
       78 OS-PC VALUE 2.
       78 OS-OTHER VALUE 3.
      *
      * These constants configure the compile ....
      *
       78 DEBUG-FLAG VALUE 1. *> Comment this out for no debug displays
       78 OS VALUE OS-UNIX.   *> Set to a valid OS- constant as above

       PROCEDURE DIVISION.
      $IF DEBUG-FLAG DEFINED
      $IF OS = OS-UNIX
           DISPLAY "Compiled for Unix".
      $ELSE
      $IF OS = OS-PC
           DISPLAY "Compiled for PC".
      $ELSE
      $IF OS = OS-OTHER
           DISPLAY "Compiled for Other".
      $ELSE
           DISPLAY "OS Constant is invalid!".
      $END
      $END
      $END
      $END
           DISPLAY "Hello World".

Note: I just typed that in and haven't compiled it, so the usual disclaimer
      applies.

This stuff is in the V4.0 Language Reference, chapter 6-4.
Usage of the command-line directive "CONSTANT" is recommended instead of
defining the DEBUG-FLAG 78 level or whatever in your program.
Alternatively, use the Animator :)

Cheers,
Kev.

--

These views are strictly my own. I doubt that anyone else would want them.
STUFF FOR SALE: <A HREF="http://www.mfltd.co.uk/~ked">Here!</A>



Sun, 31 Jan 1999 03:00:00 GMT  
 Conditional Compiles?

Quote:


> > I use MF Cobol as a workbench, then upload to MVS for production-ready
> > implementation.

> > One thing I like about C preprocessing is the IFDEF; getting debug code in the
> > source is very, very nifty and I'd really like to emulate (or enable) this for
> > COBOL.

> > Fully-forming the question: how can I accomplish debug (conditional) compiles
> > for MicroFocus COBOL (v4)?

> Hi.
> The following will achieve this. Note that the dollar signs are in column 7.

>       *
>       * These constants define the sort of OS this program can
>       * adapt to at compilation time ....
>       *
>        78 OS-UNIX VALUE 1.
>        78 OS-PC VALUE 2.
>        78 OS-OTHER VALUE 3.
>       *
>       * These constants configure the compile ....
>       *
>        78 DEBUG-FLAG VALUE 1. *> Comment this out for no debug displays
>        78 OS VALUE OS-UNIX.   *> Set to a valid OS- constant as above

>        PROCEDURE DIVISION.
>       $IF DEBUG-FLAG DEFINED
>       $IF OS = OS-UNIX
>            DISPLAY "Compiled for Unix".
>       $ELSE
>       $IF OS = OS-PC
>            DISPLAY "Compiled for PC".
>       $ELSE
>       $IF OS = OS-OTHER
>            DISPLAY "Compiled for Other".
>       $ELSE
>            DISPLAY "OS Constant is invalid!".
>       $END
>       $END
>       $END
>       $END
>            DISPLAY "Hello World".

> Note: I just typed that in and haven't compiled it, so the usual disclaimer
>       applies.

> This stuff is in the V4.0 Language Reference, chapter 6-4.
> Usage of the command-line directive "CONSTANT" is recommended instead of
> defining the DEBUG-FLAG 78 level or whatever in your program.
> Alternatively, use the Animator :)

> Cheers,
> Kev.
> Also, you don't need to use the level 78 to set the variable value, you

can use a compiler directive, test if the value has been set, and
display at compile time.

$set ans85 mf noosvs novsc2 nosticky-linkage case
$if env not defined
$set constant env "16bit"
$end
$if env = "16bit"
$set align(2) addsyn "zero" = "myzero" constant dynapi "mfwapi"
*    HANDLE is numeric so we need to compare them with ZERO
*    using "myzero".  The dynapi is the windows api .dll filename
     copy "dyncall.cpy".     *> Remaps routine names for dyn load
     copy "win16.cpy".
$else
$set align(4) addsyn "null" = "myzero" constant dynapi "cob32api"
     copy "win32.cpy".
$end

The constants can be used in nifty ways as well like:

  78  name-length                       value 128.
  01  my-name                   pic x(name-length).

  78  max-entity-rec-length       value 800.      *> Multiple of 4

  01  entity-heap-record.
   78 ent-fixed-bit-start         value next.
   03 entity-rec-len              pic x(2) comp-x. *> Use comp-x!
   03 entity-rec-type             pic x    comp-x.
   78 ent-rec-keyed               value 0.
   78 ent-rec-unkeyed-list        value 1.
   78 ent-rec-unkeyed-item        value 2.
   78 ENT-REC-EXTERNAL            VALUE 3.
   03 entity-cobol-name-entry.
      05  entity-cobol-name-addr  pic x(4) comp-x.
      05  entity-cobol-name-syn-cnt
                                  pic x    comp-x.
   03 entity-keyed-details.
      05  entity-keyed-addr       pic x(4) comp-5.
      05  filler redefines entity-keyed-addr.
       07 entity-synonym-max      pic x    comp-5.
       07 entity-first-is-01      pic x    comp-x.
       07 filler                  pic x(2).
      78  ent-heap-next-offset    value next - ent-fixed-bit-start.
      05  entity-heap-next        pic x(4) comp-x. *> Use comp-x!
      05  entity-key-len          pic x    comp-x.
      78  ent-fixed-key-len       value next - ent-fixed-bit-start.
      05  entity-rec-rest.
      78  ent-rest-rec-max        value max-entity-rec-length -
                                           ent-fixed-key-len.
       07 entity-rec-byte     pic x comp-x occurs ent-rest-rec-max.

--

Phone: +44 (0)1635 565 358, fax +44 (0)1635 565 567



Tue, 02 Feb 1999 03:00:00 GMT  
 Conditional Compiles?

Quote:

>One thing I like about C preprocessing is the IFDEF; getting debug code in the
>source is very, very nifty and I'd really like to emulate (or enable) this for
>COBOL.

If memory serves me correctly, official COBOL supports conditional
code as follows:

Put a D in column 7 of your debug lines.

These debugging lines will only be compiled if the SOURCE-COMPUTER
paragraph specifies WITH DEBUGGING MODE.

       identification division.
       program-id. test1.
       environment division.
       source-computer. Zumflot-IV with debugging mode.
       procedure division.
       begin.
      D    display "Here are the dubugging displays".
             display "This displays every time".

George Trudeau, Town of Falmouth



Mon, 08 Feb 1999 03:00:00 GMT  
 Conditional Compiles?

Remo,
If you are using a Unix platform, you might also consider placing m4
statements in the code and using the m4 preprocessor prior to
compilation.

Joan.

Quote:


> >One thing I like about C preprocessing is the IFDEF; getting debug code in the
> >source is very, very nifty and I'd really like to emulate (or enable) this for
> >COBOL.
> If memory serves me correctly, official COBOL supports conditional
> code as follows:

> Put a D in column 7 of your debug lines.

> These debugging lines will only be compiled if the SOURCE-COMPUTER
> paragraph specifies WITH DEBUGGING MODE.

>        identification division.
>        program-id. test1.
>        environment division.
>        source-computer. Zumflot-IV with debugging mode.
>        procedure division.
>        begin.
>       D    display "Here are the dubugging displays".
>              display "This displays every time".

> George Trudeau, Town of Falmouth



Wed, 10 Feb 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Conditional compiles on any build *BUT* debug?

2. Conditional Compile?

3. Conditional compiling in LV.

4. Eiffel extension for conditional compile

5. Conditional Compiling question

6. Conditional Compile

7. COMPAQ FORTRAN Conditional compile

8. conditional compiles ?

9. conditional compile for gFortran (GCC?): newbie question

10. Usage of compile ?compile >mark <mark <resolve >resolve

11. (postpone babble: using postpone in interpret-mode to compile compile-only words)

12. COMPILE, [COMPILE], POSTPONE

 

 
Powered by phpBB® Forum Software