Shop OBEX P1 Docs P2 Docs Learn Events
The Editor Erro number 123: Symbol is already defined — Parallax Forums

The Editor Erro number 123: Symbol is already defined

Dan2Dan2 Posts: 1
edited 2007-12-04 18:22 in Learn with BlocklyProp
Hey I am currently trying to use the editor for a servo controller and I have this code
'{$STAMP BS2}
' {$PBASIC 2.5}

'{$PORT COM1}
PIN VAR Byte
oldPin VAR Byte
pos VAR Byte
oldPos VAR Byte
pulse VAR Word
main:
SERIN 16,16468,old,10, [noparse][[/noparse]WAIT(255), PIN, pos]
pulse = (pos/255)*750
PULSOUT PIN,750+pulse
oldPin = PIN
oldPos = pos
GOTO main
old:
pulse = (oldPos/255)*750
PULSOUT oldPin,750+pulse
GOTO main

and when I run it it says that the PULSOUT on line 13 is already defined and wont let me run it any help????

Comments

  • Steph LindsaySteph Lindsay Posts: 767
    edited 2007-12-04 18:17
    Hi Dan2,

    For starters, you can't use PIN as a variable name to declare a variable, because it is already a reserved word in the PBASIC 2.5 language.· Try changing all instances of PIN to something else.·

    I think there will be another problem with your SERIN statement too, WAIT is also a reserved word.· Take a look at the syntax description for SERIN·in the BASIC Stamp Editor's Help.· The Timeout argument might·be what you need there, but it doesn't go in the square brackets.

    Hope this·helps,

    -Stephanie Lindsay

    Editor, Parallax Inc.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-12-04 18:19
    You've tried to define a variable named "PIN". PIN is a reserved symbol in PBASIC and can't be used as a variable name. Change it to something else, e.g. "VPIN". When you do that, though, you'll get another error in your SERIN statement. This can be resolved by referring to the manual.

    In any event, the compiler seems to have gotten confused, and should have flagged the VAR statement where PIN was first defined. But at least it knew something was wrong.

    -Phil
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-12-04 18:22
    Dan2 -

    The problem is that PIN is a PBASIC reserved word. So, in a real sense it is already defined, in the PBASIC compiler's dictionary of reserved words. A list of the PBASIC reserved words can be found in one of the appendices of the PBASIC Reference Manual.

    Change PIN to IO_Pin if you wish or anything similar that's not a reserved word.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.