Trouble with Syntax BS2
KennyK
Posts: 4
Hello,
I am having some trouble where the code does not let me run since it fails the syntax test. I cannot figure out what I am doing wrong.
The compiler keeps telling me that I need an IF before the Else.
Here is part of the code:
I am having some trouble where the code does not let me run since it fails the syntax test. I cannot figure out what I am doing wrong.
The compiler keeps telling me that I need an IF before the Else.
Here is part of the code:
' {$STAMP BS2} 'This indicates to use a Basic Stamp 2 module' {$PBASIC 2.5} ' Use the PBasic 2.5 language, which provides additional commands ' Constants period CON 329 ' period = 330 msec pw CON 49 ' pulse width = 50 msec, proper PW is 15-75 ms shortpw CON 13 'set the short pulse to 2 ms less than the min pulse width longpw CON 77 'set the long pulse to 2 ms longer than the max pulse width magneton PIN 0 'magnet sensor is on Pin0 sweephand PIN 1 'sweep hand input is on Pin1 switch1 PIN 3 'switch to select short pulse switch2 PIN 4 'switch to select long pulse switch3 PIN 5 'switch to select missing pulse 'Pin2 is the output line for the RTR pulses INPUT switch1 INPUT switch2 INPUT switch3 INPUT magneton INPUT sweephand ' Variables x VAR Byte ' for/next loop counter LOW 2 'Set P2 to low to initialize it Watch: IF (magneton = 1 AND sweephand = 1) THEN Watch 'Loop here until the magnet moves (switch pulls input low when movement detected) ELSE Begin 'magnet moved, so go to pulse output section ENDIF
Comments
Verify that your syntax is correct by checking the built-in help in the editor. Try also temporarily removing the comments from the "IF"-related rows
The INPUT commands where missing in the Watch subroutine
The AND was in the parens
GOTO was missing on both branches
"Begin" was missing as a subroutine, (I renamed it "SomethingElse"
I initially had the GOTO in there, but it was giving errors (I had it in the wrong spot). When I removed it, I was getting the IF errors.
Now it downloads to the Stamp.