View Single Post
  #4   Spotlight this post!  
Unread 19-01-2003, 11:09
Ameya's Avatar
Ameya Ameya is offline
Freelance Goon
FRC #0293 (SPIKE Robotics)
Team Role: Alumni
 
Join Date: May 2001
Rookie Year: 2000
Location: Pennington, NJ
Posts: 67
Ameya is on a distinguished road
Send a message via ICQ to Ameya Send a message via AIM to Ameya
Quote:
if (p1_y > 135) then skip:
skip:
relay1_fwd = 1
In PBasic 1.33 and earlier, if-then branching works like this: if the condition is true, then execution continues at the label following "then"; if it is false, then execution continues at the next statement. In your statement, the label "skip:" comes immediately after the if statement, so it is executed in both cases. Here's what it should look like:

if (p1_y > 135) then skip:
relay1_fwd = 0         &n bsp;   'the "else" case
goto endif:       &n bsp;'without this, execution would just continue at the next line, "skip"

skip:
relay1_fwd = 1         &n bsp;    'the "then" case

endif:
__________________
Ameya Agaskar
Team 293 alumnus