
19-02-2003, 18:34
|
 |
do you..
no team
|
|
Join Date: May 2001
Rookie Year: 2000
Location: San Jose, CA
Posts: 1,445
|
|
|
Re: loops inside of subs???
Quote:
Originally posted by manodrum
hi, i have written a little code that will fire our pistons for approx. 3 seconds when one of the joystick buttons is pushed, so I wrote an if statement after the SERIN that
"if p2_sw_trig = 1 then GOSUB FIRE3"
that works and sends it to my sub code which looks like this:
FIRE3:
relay1_fwd = 1
MyCounter VAR byte
StepSize VAR byte
MyCounter = 1
FOR MyCounter = 1 TO 3001 STEP StepSize
StepSize = delta_t * 25
NEXT
relay1_fwd = 0
RETURN
but once i push the trigger, i get a basic run error, but, when i take away the FOR...NEXT statements, everything works, what's up with this? can i not do loops inside of subs? thanks a lot
Stephen
|
MyCounter is declared as a byte. A byte can store a number no larger than 254. After that it loops around to a negative number (an illusion).
__________________
Joel Johnson
Division By Zero ( 229) Alumni, 2003-2007
RAGE ( 173) Alumni, 1999-2003
|