View Single Post
  #1 (permalink)  
Old October 31st, 2004, 05:57 PM
CNewbie CNewbie is offline
Authorized User
Join Date: Mar 2004
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Lookup (Dispatch) Table

Hi all:

I am still learning c++, so I will try to describe my problem and what I am try to do the best I can.

The basis of my program is to take data from the Serial I/O Port into a character array and analyze it and do all kinds of stuff with it. Right now what I am trying to do is take a byte (I am working with whole numbers, so my byte would = 2 characters) and compare it against a table of possible matches and if the byte matches, go to the function that corresponds with that byte.

I'll give an example here:

Lets say the whole number integer is 48. Now I want to take 48 and compare it against a list of commands (00 to 99) and if one matches go to the routine of that matching number. so when it compared 48 against 48 in the table it would then call the cmd48() function and go from there.

I hope I have been as clear as possible, so that you can understand what it is I am trying to do.

NOTE: I dont think a switch-Break statement would work since it only checks 1 character and obviously I am not working with only 1 character, so I dont know anything else to use.


Reply With Quote