Shop OBEX P1 Docs P2 Docs Learn Events
Pbasic Syntax — Parallax Forums

Pbasic Syntax

Roger PiersonRoger Pierson Posts: 62
edited 2006-10-17 15:28 in BASIC Stamp
Hello,

I was wondering what the difference between these two statements is:

TM PIN 12



and

TM CON 12



Both appear to do the same thing, allow pin 12 to be referenced by TM. I assume there is an advantage to using one method over the other, would somebody be kind enough to show me to the light?

Thanks,

Roger

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Roger Pierson
Senior Electronics Technicain
DTI Assoicates

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-16 22:02
    The difference is that defining TM with a PIN declaration allows you do write "IF TM <> 1" or "TM = 0". The compiler automatically translates the first into "IF IN12 <> 1" and the second into "OUT12 = 0". Read the Basic Stamp Manual, revision 2.2 for a discussion.
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-10-16 22:16
    Also, the "PIN" declaration only works on version 2.5 of the compiler. The "CON" version works on the earlier version, BUT you must declare the pin INPUT or OUTPUT, and even then, you might need an IN1 declaration to actually 'read' the state of the pin. the "PIN" declaration takes care of that sort of thing for you.
  • FranklinFranklin Posts: 4,747
    edited 2006-10-16 23:01
    The first sets TM to pin 12 and the second sets TM to 12

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-10-16 23:26
    When PBASC 2.5 first came out there was confusion about that difference. I have a little writeup here, emesys.com/BS2pbasic25.htm#PIN_examples, that goes into more examples. There may be rare cases where you want CON or VAR instead of PIN.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Roger PiersonRoger Pierson Posts: 62
    edited 2006-10-17 15:28
    Thanks for the info, folks. I was thinking it had something to do with the amount variable space each command took up or something along those lines. Thanks for straightening me out!

    Tracy, that was a fantastic article. Thanks!

    Roger

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Roger Pierson
    Senior Electronics Technicain
    DTI Assoicates
Sign In or Register to comment.