Thread: Ok one problem
View Single Post
  #3   Spotlight this post!  
Unread 13-02-2003, 01:00
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,560
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
assuming you want to use pbasic 2.0 syntax, the easiest way (that I have found) to keep everything straight is to do something like this:
Code:
if condition1 then do_condition1
if condition2 then do_condition2
if condition3 then do_condition3
'add else condtion here if necessary
goto end_conditions

do_condition1:
   'condition1 code here
goto end_conditions

do_condition2:
   'condition2 code here
goto end_conditions

do_condition3:
   'condition 3 code here
goto end_conditions

end_conditions:
'increment counter or whatever else you want to do.
doing this allows you to add as many conditions as you want very easily.

this would be equivilent to a nested if...else if...else if...else statement in C.