Thread: The New PBASIC
View Single Post
  #11   Spotlight this post!  
Unread 07-01-2003, 21:02
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
No. It's like

ON counterVar GOSUB label0, label1, label2, label3, label4, label5

There may be brackets in there, but I don't remember.

Anyway, if counter counterVar has the value 0, it will GOSUB to label0. If it's 1, GOSUB label1, etc. It's identical to BRANCH, except you can do a GOSUB instead of just the equivalent of GOTO. Note that you can similuate a BRANCH exactly by doing

ON counterVar GOTO label0, etc.


As for the code you posted, PBASIC now supports what I like to call one-line-ifs, meaning you can do
if p2_y>30 then gosub exit

Similarly, you can do stuff like:
if (p1_y < 140 AND p1_y > 117) then p1_y=127
Mmmm... tasty.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php