Shop OBEX P1 Docs P2 Docs Learn Events
BS1: PIN5 = PIN5 syntax error — Parallax Forums

BS1: PIN5 = PIN5 syntax error

WoodwiseWoodwise Posts: 6
edited 2006-07-13 19:04 in BASIC Stamp
Following the example in the manual, I programmed
NoClockEvent:
PIN5 = PIN5
TOGGLE 5

But the editor flags this with an error msg:
"Expected an operator"

Huh? It's just an assignment, isn't it?

~Rich

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-13 16:46
    I don't know for certain, but I suspect the editor is trying to protect you from a "do nothing" operation that may not be supported by the interpreter. It looks like it ought to work. Try changing one of the "5"s to a "4" and see what happens.
  • WoodwiseWoodwise Posts: 6
    edited 2006-07-13 18:11
    Thanks for that! I tried it and it passed. So I now have

    TempWork = PIN5
    PIN5 = TempWork
    TOGGLE 5
    which also passes. Still, it uses a variable, and what I did at first is in the book. Maybe PBasic can't really do the assignment, so they have changed the syntax checker to accomodate that...

    ...but
    TempWork = TempWork
    doesn't work!! So it looks like you are correct, though why the syntax checker cares, I dunno...and I now wonder if I really need PIN5 = PIN5 as the book and the Help both say...

    ~Rich
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-07-13 18:20
    PIN5 = PIN5 * 1

    [noparse][[/noparse] A = A ...what a concept. ]
  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-13 18:29
    Theoretically, the PIN5=PIN5 assignment makes sense. The right side accesses the input pin directly and returns the current state of the pin. The left side accesses the output latch, so the assignment copies the current state of the input pin to the latch register. Whether the latch is connected to the pin or not depends on the state of the DIR5 bit. The TOGGLE always sets the DIR bit to zero (output), but, if it was set to one before (input), the Stamp samples the input pin, copies it to the output latch, changes the output latch to its opposite, and makes it an output.
  • Paul Sr.Paul Sr. Posts: 435
    edited 2006-07-13 18:33
    Mike Green said...
    Theoretically, the PIN5=PIN5 assignment makes sense. The right side accesses the input pin directly and returns the current state of the pin. The left side accesses the output latch, so the assignment copies the current state of the input pin to the latch register. Whether the latch is connected to the pin or not depends on the state of the DIR5 bit. The TOGGLE always sets the DIR bit to zero (output), but, if it was set to one before (input), the Stamp samples the input pin, copies it to the output latch, changes the output latch to its opposite, and makes it an output.

    YIKES!!! freaked.gif
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-07-13 19:04
    Rich -

    Please do me a favor in the future. When you post something like this:

    quote

    Following the example in the manual, I programmed
    NoClockEvent:
    PIN5 = PIN5
    TOGGLE 5

    end quote

    PLEASE say something like this:

    Following a technique I found in the PBASIC Manual, which I modified somewhat, blah blah blah.

    Although there IS such an example in the PBASIC Manual, there is no way one can ferret it out by using what you indicated. The (nearly) verbatim example is as follows:

    PIN2 = PIN2 ' make output driver match input
    TOGGLE 2 ' then toggle

    Just as a sidenote that is a BS-1 ONLY example. The BS-2 example follows it. Additionally, I AGREE that the PBASIC Manual indicates that it should work on a BS-1. According to my brief testing, it does NOT, as you found out. The sample example is found here - REF: "PBASIC Stamp Syntax and Reference Manual 2.2", actual PDF page 460, indicated page 456.

    Am I just being picky about semantics? You tell me - I just spent almost an hour searching ALL of the Parallax Manuals in PDF form (and I have hundreds of them - old and new) looking for that example. I came up dry! Then it dawned on me that you might have modified the example, and it only took 30 more SECONDS from that point.

    Thanks for helping us out, who are willing to help yousmile.gif

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->

    Post Edited (Bruce Bates) : 7/13/2006 7:15:20 PM GMT
Sign In or Register to comment.