Shop OBEX P1 Docs P2 Docs Learn Events
Comment out a block of code? Yes, there is ... — Parallax Forums

Comment out a block of code? Yes, there is ...

ArchiverArchiver Posts: 46,084
edited 2003-12-12 13:51 in General Discussion
No questions are stupid.

There is a trivial way to do what you want.

Read PBasic Compiler 2.0 Beta 2.pdf pages 1 and 8.

Page 2 tells you how to turn on PBasic 2.5, i.e.,
' {PBASIC 2.5}
It is a compiler directive.

Page 8 explains how to use the #define and #if compiler directives.


I haven't used this with the PBasic compiler, but many others.

It should look something like:


' {PBASIC 2.5}

#DEFINE IncludeLines = 1


#IF IncludeLines = 1 #THEN
blah, blah blah this stuff is included and will cause
compile errors
#ENDIF


Take care,
Frank




--- In basicstamps@yahoogroups.com, laurasdog@w... wrote:
> Sorry in advance for the stupid question...
>
> Is it possible to "comment out" a whole block of
> code at once for testing, or do I have to do it
> 'one
> 'damned
> 'line
> 'at
> 'a
> 'time?
>
> Is kind of a pain to disable several dozen lines
> at once sometimes.
>
> Is there an easy way out?
>
> Thanks much!
>
> Steve D. - official newbie stamper
>
> ----

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-12-12 13:51
    Technically, that's not block commenting, it's conditional compiling.
    That said, the result is the same (with a tad more work) and it's a
    clever use of the process that I should have thought of myself since I
    often use it to selectively enable/diable DEBUG output.

    You can simplify a bit:

    #DEFINE _DebugOn = 1

    ...

    #IF _DebugOn #THEN
    ' block of code
    #ENDIF


    Conditional compilation symbols are either defined or are not, so you
    don't need to check for a value in the #IF-#THEN block. My personal
    preference is to prefix conditional compilation symbols with an
    underscore so I know they are different from standard constants.

    Happy Holidays.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: franksmith512 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Rtpx582ycDB3j15duqnmjatOYr-FdLziZodOV30zflE9PVkVClXF8gD0BxlVpEyK1SFzTR-yNekCp7rGB_oiat4]franksmith512@y...[/url
    Sent: Thursday, December 11, 2003 7:14 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: Comment out a block of code? Yes, there is
    ...


    No questions are stupid.

    There is a trivial way to do what you want.

    Read PBasic Compiler 2.0 Beta 2.pdf pages 1 and 8.

    Page 2 tells you how to turn on PBasic 2.5, i.e.,
    ' {PBASIC 2.5}
    It is a compiler directive.

    Page 8 explains how to use the #define and #if compiler directives.


    I haven't used this with the PBasic compiler, but many others.

    It should look something like:


    ' {PBASIC 2.5}

    #DEFINE IncludeLines = 1


    #IF IncludeLines = 1 #THEN
    blah, blah blah this stuff is included and will cause
    compile errors
    #ENDIF


    Take care,
    Frank




    --- In basicstamps@yahoogroups.com, laurasdog@w... wrote:
    > Sorry in advance for the stupid question...
    >
    > Is it possible to "comment out" a whole block of
    > code at once for testing, or do I have to do it
    > 'one
    > 'damned
    > 'line
    > 'at
    > 'a
    > 'time?
    >
    > Is kind of a pain to disable several dozen lines
    > at once sometimes.
    >
    > Is there an easy way out?
    >
    > Thanks much!
    >
    > Steve D. - official newbie stamper
    >
    > ----


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
Sign In or Register to comment.