Go to Post Eating at Pappy's is the only St Louis activity for me. - Cory [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 21-02-2005, 20:44
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Running Once?

Where can I put my code so that it will execute itself completely only one time. So, if I turn the bot off and on, it will run again. There was a section in the UserRoutines.c FUNCTION NAME: User_Initialization that says it only runs once, but this doesn't seem like the right place for my code.
  #2   Spotlight this post!  
Unread 21-02-2005, 22:52
probizzle's Avatar
probizzle probizzle is offline
Registered User
AKA: Prabhas Pokharel
#0639 (Code Red)
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2003
Location: Ithaca
Posts: 78
probizzle will become famous soon enoughprobizzle will become famous soon enough
Send a message via AIM to probizzle
Re: Running Once?

Make a function somewhere in user_routines.c, put your code in there, and call that function from User_Initialization.

At least if you are trying what I think you are trying to do.
__________________
Code Red Team 639 Winners of the 2005 FingerLakes Regional with 191 and 494.
--
http://pset.deu83.com << my baby
http://www.setgame.com/set/ << it's mother
  #3   Spotlight this post!  
Unread 22-02-2005, 12:31
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Re: Running Once?

What is stopping the program from going down the program and calling it, then it hits it again later and runs it? Is this programming language run-by-call-only and not run down the program. Right now I went into the users initialization and just pasted in my code snipet after where it says */Add you own...*/. Looks kind of messy, but only the robot will know .
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #4   Spotlight this post!  
Unread 22-02-2005, 13:58
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: Running Once?

Quote:
Originally Posted by amateurrobotguy
What is stopping the program from going down the program and calling it, then it hits it again later and runs it? Is this programming language run-by-call-only and not run down the program. Right now I went into the users initialization and just pasted in my code snipet after where it says */Add you own...*/. Looks kind of messy, but only the robot will know .
Yes, it's "run by call" only. It will only run when it is called.

At least it's supposed to...
__________________

  #5   Spotlight this post!  
Unread 22-02-2005, 15:28
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Re: Running Once?

Once I call my function, does the function need to link back to the user initialization part just before it left off. I am assuming that it will automatically go back to right after where it was called upon completetion.
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #6   Spotlight this post!  
Unread 23-02-2005, 01:30
Ryan Cumings's Avatar
Ryan Cumings Ryan Cumings is offline
Programmer and University Rejected
#0134 (Team Discovery)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2000
Location: Pembroke, NH
Posts: 65
Ryan Cumings is an unknown quantity at this point
Send a message via AIM to Ryan Cumings
Re: Running Once?

Quote:
Originally Posted by amateurrobotguy
Once I call my function, does the function need to link back to the user initialization part just before it left off. I am assuming that it will automatically go back to right after where it was called upon completetion.
Once you call the function, it will return to the point from where it was called once the function has returned
(If you didn't put in a return than the compiler will insert one for you at the end of the functions definition)
__________________
Suddenly being rejected from college feels right during the build season. Now I am a mentor.
  #7   Spotlight this post!  
Unread 23-02-2005, 07:34
SpeakerSilenced SpeakerSilenced is offline
Programming/Electrical Team Member
#0219 (Team Impact)
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Hackettstown, NJ
Posts: 28
SpeakerSilenced is an unknown quantity at this point
Send a message via AIM to SpeakerSilenced
Re: Running Once?

There is a simpler way of having something only run once...
Code:
int counter = 0;
if (counter == 0)
{
do whatever you want once;
counter++;
}
It will never be executed again unless you set counter = to 0... you can change the variable name too and name it whatever the function is supposed to do such as camera_settings, etc...
__________________
"I want to put a ding in the universe" - Steve Jobs
  #8   Spotlight this post!  
Unread 23-02-2005, 15:33
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,579
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
Re: Running Once?

Quote:
Originally Posted by SpeakerSilenced
There is a simpler way of having something only run once...
Code:
int counter = 0;
if (counter == 0)
{
do whatever you want once;
counter++;
}
It will never be executed again unless you set counter = to 0... you can change the variable name too and name it whatever the function is supposed to do such as camera_settings, etc...
That will be called every time unless counter is declared as a static int
Closed Thread


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
Kitbot/cims/transmissions running too slow? Swampdude Technical Discussion 28 23-01-2005 11:17
Running OSX 10.3 on a Macintosh Centris Joe Matt Chit-Chat 4 27-10-2004 00:37
Dual sites on home server running apache? Mike AA IT / Communications 7 28-08-2004 02:02
A vampire running for office MissInformation Chit-Chat 2 30-08-2003 14:36
The WebCam is Up and running archiver 2001 0 23-06-2002 23:08


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

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