squirrelix
July 1st, 2007, 04:33 AM
Hey kids,
I am writing a program, and I keep adding variables. For each variable, I need to add it to a help menu, as well as the code to change the value.
Then I wondered. Is there a way to store your program variables (global ones) in a data structure that you could iterate over. I looked at a hash table, (Using Java at the moment), but the code to tweak the variable is ugly. (Get the object from the table, cast to a float, add a value to it, stuff it back in the table).
This is really a "has anyone else wondered about this" kind of question. I understand that in certain languages, you can have variable name variable names (no, not a typo :P). Can anyone verify that?
Thanks, and just curious.
-- Squirrel
I am writing a program, and I keep adding variables. For each variable, I need to add it to a help menu, as well as the code to change the value.
Then I wondered. Is there a way to store your program variables (global ones) in a data structure that you could iterate over. I looked at a hash table, (Using Java at the moment), but the code to tweak the variable is ugly. (Get the object from the table, cast to a float, add a value to it, stuff it back in the table).
This is really a "has anyone else wondered about this" kind of question. I understand that in certain languages, you can have variable name variable names (no, not a typo :P). Can anyone verify that?
Thanks, and just curious.
-- Squirrel