Go to Post Only two letters and one punctuation mark can describe my feelings about this... NNNOOOOOOOOOOO!!! :( - Qbranch [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 02-03-2005, 18:54
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
Look-Up Table

Would this concept be valid:

table(1)=5;

i=1
j=0

j=table(i);

"J"should return 5.

In BASIC, I would have to set the start to be 0, use a dim to se ther range to X. Is this necessary in C?

Thanks In Advance
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).

Last edited by amateurrobotguy : 02-03-2005 at 19:11.
  #2   Spotlight this post!  
Unread 02-03-2005, 19:47
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
Question Re: Look-Up Table

Quote:
Originally Posted by amateurrobotguy
table(1)=5;

i=1
j=0

j=table(i);

"J"should return 5.
Could you please give more detailed examples next time?
At least show all variable declarations and functions with the important algorithm chopped off.
I'm sorry, but the code pieces you show aren't detailed enough (they don't show types or declarations -- just use bogus numbers or something)

I assume what you have in the code is something like:
Code:
/* Make sure to initialize your array. */
/* int variable[LENGTH]={val1,val2,val3,...} */
int table[10]={3,2,1,6,5,4,9,8,7,0};

void myfunction (void) {
    int i=1;
    int j=0;
    j=table[i]; // Will give you "2", not "3": indicies start at 0, not 1
    // Was that your question?
}
__________________
-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...
  #3   Spotlight this post!  
Unread 02-03-2005, 20:01
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: Look-Up Table

Yes, I believe that was my answer. I assume that I can delacre my array outside all functions and have it available everywhere too. My example would work in Basic(hopefully)
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #4   Spotlight this post!  
Unread 03-03-2005, 18:00
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: Look-Up Table

Is this the proper format then for a table:

rom const int table[5]={1,
2,
3,
4,
5};

Will the multiple lines confuse it?
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).
  #5   Spotlight this post!  
Unread 03-03-2005, 18:19
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Look-Up Table

Quote:
Originally Posted by amateurrobotguy
Will the multiple lines confuse it?
C compilers ignore whitespace, so you should be fine.
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
Lookup table generation tool WillyC Programming 12 15-02-2004 21:01
2-3 minute Interview at Pit Table ben_whly Chairman's Award 5 01-04-2002 16:00
table corruption... round 2 Brandon Martus Announcements 0 18-12-2001 23:57
table corruption Brandon Martus Announcements 2 20-11-2001 05:16


All times are GMT -5. The time now is 04:41.

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