View Single Post
  #9   Spotlight this post!  
Unread 04-03-2005, 00:40
ace123's Avatar
ace123 ace123 is offline
Registered User
AKA: Patrick Horn
FRC #0008 (Paly Robotics - http://robotics.paly.net/)
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Palo Alto, CA
Posts: 50
ace123 has a spectacular aura aboutace123 has a spectacular aura about
Send a message via AIM to ace123
Re: Static Variables

Actually, you can not put explicit code outside of functions, but you are allowed to put initial values for all variables. These must be constants, and can only be either arrays like (1,45,3,21,4,5...} or integers like 2.
They can also include basic expressions like:
Code:
#define M_PI 3.14159265358979
int my_circumference=2*M_PI
This code is executed, and I think that's what the ".cinit" seciton in your map file is for.

But, no actual code is allowed, and the order in which variables are initialized is also undefined. So you can and should only use this to initalize defaults. If you do not do this, then the variables will be uninitialized, meaning that they could start out with any value.

If you want code to run, then put all of that in your User_Initialization(). Beware that no pwms or inputs or control inputs can be read or written in the initialization function.
__________________
-Patrick Horn, Paly Robotics

Check out the space simulator called Vega Strike, modelled after the space simulator games Elite and Wing Commander. It's Open Source too!
If you have ever played Wing Commander, or especially Privateer, and had a feeling of nostalga derived from the you will enjoy these two Vega Strike mods: Privateer Gemini Gold and Privateer Remake!
I'm working on adding multiplayer support this year...