Shop OBEX P1 Docs P2 Docs Learn Events
What is the point of this code? — Parallax Forums

What is the point of this code?

Bosco312Bosco312 Posts: 1
edited 2009-01-31 17:33 in BASIC Stamp
I want to point out that I looked for a pinned note of FAQ questions first (which I didn't find; feel free to point it out), and second, I did a search, but the bit that I have a question about is in SO many posts, that search didn't help.

So here is my question...

All the example programs in my books (Toddler and SumoBot) start with the following...

' {$STAMP BS2}
' {$PBASIC 2.5}

To me, it seems this code is commented out, and thus is only for the reference of anyone who might look at the code. So why is it always formatted the way it is and not something like...

' Stamp BS2, PBASIC 2.5

Does this not accomplish the same thing? I suspect having it in the 'standard' format means something, but I don't know what.

Educate me, please.

Comments

  • ZootZoot Posts: 2,227
    edited 2009-01-28 22:29
    Read the Pbasic Manual under compiler directives. You can download it from the Parallax site; the printed version is often included with Stamp board packages, and all the info in the manual can be browsed by "help" when you are in the Stamp Editor program.

    In this case, the first directive tells the compiler to use Pbasic 2.5 (rather than 2.0). The second directive tells the compiler which flavor Stamp the program applies to.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • SRLMSRLM Posts: 5,045
    edited 2009-01-29 02:07
    In a similar vein are proprocessor directives, which start with # and allow you to take care of some special cases.
  • $WMc%$WMc% Posts: 1,884
    edited 2009-01-29 11:55
    Bosco312

    Take a look in the upper left hand corner at "Directives".(In the editor window) Click on it and You'll see the drop down windows. This selection will paste the Directives for You. It saves a little typing at the start of a new project.


    _____________$WMc%______

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • normandnormand Posts: 1
    edited 2009-01-31 17:33
    The code does a bit more than just tell the reader what the processor and code version in use are. the code ' {$PBASIC 2.5} is basically a comment AND a command (indicated by the {}). It initializes the program interface to present typed code as 'active' elements (basically color codes and recognize program formatters, commands, normal text, etc.). Simply typing the code may no be enough either. it is best to initialize this code via the buttons at top of the BASIC Stamp editor (relative to your code/IC version). Simply typing the code may not prompt the code-recognition function.

    Typing the code as you suggested: ' Stamp BS2, PBASIC 2.5 makes the code only a comment and does will not allow for the command/format properties to be utilized. It has to be in the format
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}


    Hope this helps!
Sign In or Register to comment.