• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • RPG IV Comment Blocks

    December 8, 2004 Hey, Ted

    Conditional compilation directives (/IF DEFINED) have two good uses that I have not seen mentioned in any of the midrange-oriented e-mail newsletters. Maybe you would like to tell your readers who work in RPG shops about them.

    One good way to use a conditional compilation directive is to comment-out large sections of source code. Here’s an example.

     /if defined(TheFollowingIsCommentedOut)
    C                    eval      *in21 = *on
    C                    eval      *in22 = *off
    C*                   eval      *in23 = *on
    C                    if        *in24
    C                    exsr      DoSomething
    C                    exsr      DoSomethingElse
    C                    endif
     /endif
    

    I prefer this technique to that of commenting out each line individually. For one thing, it’s quicker to insert two lines of compiler directives than to key an asterisk (*) into column 7 of a lot of lines. Another thing I like is that I won’t accidentally remove the asterisk in column 7 of the third line if I have to reactivate this section of source code at a later date.

    I also like to use conditional compilation directives when including blocks of documentation in my source code. The following section of source code explains the meanings of the values of a customer invoicing option field.

      /if defined(TheFollowingIsAComment)
    
       Invoicing options:
    
         Generate the appropriate type of invoice
         according to the invoicing option code.
    
         E - email
         F - fax
         I - mail
         X - do not send an invoice to the customer
    
      /endif
    

    You can use the full source line for documentation with this approach, but the source code editor may not like it. SEU will not complain if the comments start in column 8 or after.


    Each of these examples works because I never define conditions called TheFollowingIsAComment or TheFollowingIsCommentedOut. Any series of characters, even garbage, works as long as no condition is defined by that name. Worrywarts may prefer to undefine the condition to be sure.

     /undefine TheFollowingIsCommentedOut
     /if defined(TheFollowingIsCommentedOut)
    

    –Cletus the Codeslinger

    Click here to contact Ted Holt by e-mail.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    OCEAN User Group

    OCEAN TechCon25 Online

    It’s an Exciting Time for IBM i !

    July 16 & 17, 2025 – ONLINE

    Two virtual days of learning, presented by an outstanding group of IBM’ers and IBM Champions, featuring leading-edge topics.

    FREE for OCEAN members!

    Register NOW!

    Annual (12-month) Individual OCEAN Memberships are $80 and a Corporate Membership is $250. A Corporate Membership would allow your entire company to have full access to the OCEAN website & video library and to attend OCEAN events at member rates. Act now because rates are increasing on August 1, 2025.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Bsafe Gets New OS/400 Security Solution Out the Door IBM Promotes the i5 on Prime-Time Television

    Leave a Reply Cancel reply

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • With Power11, Power Systems “Go To Eleven”
  • With Subscription Price, IBM i P20 And P30 Tiers Get Bigger Bundles
  • Izzi Buys CNX, Eyes Valence Port To System Z
  • IBM i Shops “Attacking” Security Concerns, Study Shows
  • IBM i PTF Guide, Volume 27, Number 26
  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle