Go to Post Differentiating based on any superficial criteria (gender, race, or other demographic) only serves to reinforce the false idea that they matter. - JamesCH95 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 19-02-2003, 18:34
Joel J's Avatar
Joel J Joel J is offline
do you..
no team
 
Join Date: May 2001
Rookie Year: 2000
Location: San Jose, CA
Posts: 1,445
Joel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond reputeJoel J has a reputation beyond repute
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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Grease inside the Drill Motor gear box? archiver 2000 2 23-06-2002 23:07


All times are GMT -5. The time now is 21:22.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi