# A strange question, I know.

Show 80 post(s) from this thread on one page
Page 2 of 2 First 12
• 01-30-2008
Elysia
Yeah, I proposed maps and made an example of a working system in the thread I linked to.
• 01-30-2008
cyreon
Actually since I am seeking technically a map between one definition to another (both of which are number based, even though they technically use different mathematical bases) I think a map would do just fine for what I need to accomplish.

0x034 (e.g.) needs to be mapped to 15

thus when the msg 0x034 comes in to my message handler, I access the appropriate function pointer via... ptrArray[15](parameters);

Thanks for the advise Elysia, a great help as always :)
• 01-30-2008
Elysia
Well, you don't really need to re-map the number of message at all. Since all messages have unique numbers, you can just map them to a function pointer directly, if you wish and pass any argument you think may be useful.
The map example I made in the other thread is just a basic map-to-pointer example. If you modify the function pointer typedef, you should be able to map whatever number you want into appropriate function pointer and function handler.
It's open to modifications.
• 01-30-2008
cyreon
Perfect. I guess I was so wrapped up in my own concept idea, it didn't even occur to me to take my own defines out of the equation. Thanks again :)
• 01-30-2008
matsp
Quote:

Originally Posted by cyreon
Perfect. I guess I was so wrapped up in my own concept idea, it didn't even occur to me to take my own defines out of the equation. Thanks again :)

It is quite common to "get stuck in the idea". Sometimes it helps to explain a bigger picture to someone else, and the other person may come up with a better idea of how this can be done [which is why I often ask for "what's the big picture" in threads where someone is asking "How do I ..."].

Generally discussing ideas for solutions help, of course.

--
Mats
• 01-30-2008
CornedBee
It's wonderful to explain the bigger picture to someone.

"So I need to make the ball hop down the hall and therefore I need to ... need to ... what am I doing this nonsense for?"
• 01-30-2008
matsp
Quote:

Originally Posted by CornedBee
It's wonderful to explain the bigger picture to someone.

"So I need to make the ball hop down the hall and therefore I need to ... need to ... what am I doing this nonsense for?"

Oh, yes, the number of times I've had that experience: Explain something clearly to someone else, and you immediately realize what you are doing wrong...

--
Mats
• 01-30-2008
CornedBee
The nice thing that it works even with non-programmers. I habitually explain my problems to my father, who can barely follow me. Still helps.
Show 80 post(s) from this thread on one page
Page 2 of 2 First 12