Guest yatpeak Posted October 31, 2003 Report Posted October 31, 2003 Hey Guys, Sorry I haven't been on for a while. I have a question completely unrelated to SPs, but I've noticed that a few of you at MoDaCo program games and apps in C++ and I was hoping you used Visual. If so, does anyone know how to evaluate a string into a variable name? If you do, it'd be a huge help! Thanks, Wyatt
Guest yatpeak Posted October 31, 2003 Report Posted October 31, 2003 Sorry, thought I should explain better what I mean. I currently have a string, m_bmp0_0, which I want to use to call the variable m_bmp0_0. How would I go about this? Thanks, Wyatt
Guest Richie M Posted October 31, 2003 Report Posted October 31, 2003 Moved to Development C++ section yatpeak :) Hope Spacemonkey's help on IRC sorted you out :(
Guest moo_ski_doo Posted November 8, 2003 Report Posted November 8, 2003 I could be wrong but I'm pretty sure that this isn't possible. The variable's ID within your code is purely for your convenience; all the machine is interested in is the address of the variable, so when your code is compiled in to machine code the variable's ID is completely lost, so it wouldn't make sense to be able to access it like this. The best solution that would achieve anything like this that I can think of is to have some sort of structure containing pointers to the variables and their string equivelants eg. struct VariableAndStringStruct { int *nVariable; TCHAR szVariableString[20]; }; Then you could use the string within this structure to do whatever you want with its associated variable. Of course this approach might be useless since I have no idea what you actually want to do with your variable strings :? Hope this helps; sorry if it hasn't been much use!
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now