The Editor Erro number 123: Symbol is already defined
Dan2
Posts: 1
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????
'{$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
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.
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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔