Referencing a variable through value of another variable

For questions about using Classic.

Post » Mon Oct 11, 2010 7:48 am

Can i do this?

For example, let's say I have a family Items, with teh private variable Category. I also have a bunch of global variables such as Weapon, Boots, Gloves, Helmet, etc, each set to its own number (Weapons =1, Boots =2, etc). Then, when I check the value of the private variable Category, which is a string, it might return Weapon, which I then want to convert to the corresponding number 1. So the expression would be global('Items.Value('Category')') which I would wnat to return 1, but it doesn't. Any way I can do that somehow? I realize I can just skip the global entirely and make category correspond to the right number. It's just easier in the long run to have text categories instead of having to refer back to a document for what each category number is.
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Mon Oct 11, 2010 6:22 pm

Instead of using global variables use a hash table.

Ex:
[url:2493g58c]http://dl.dropbox.com/u/5426011/examples2/hash.cap[/url:2493g58c]
made in 0.99.95
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests