How do I use the text inside of a variable as the name of the variable I want to retrieve?
Like this:
GlobalVariable(GlobalVariable(use-the-text-inside-of-this-variable-as-the-name-of-a-variable))
This is what I want to do:
- I have a variable that is a structure. It has many children, like “List.child1”, “List.child2”, “List.child3”, etc.
- The structure will eventually grow, so the variable might have hundreds of children.
- I use a variable called “random-number” to choose the name of the child that I want to retrieve from the structure. If the random number is “8”, a variable called “list-item-that-was-chosen” will have this text as its value: “List.child8”.
- How do I use the value of “list-item-that-was-chosen” as the name of the variable to call?
I tried this and it didn’t work: GlobalVariable(GlobalVariableString(list-item-that-was-chosen))
I tried many variations of that, and many other methods, and they didn’t work.
Here is the overall idea:
- a variable is called “random-number”. Pretend it equals 8.
- a structure variable is called “List”: “List.child1”, “List.child2”, etc.
- a variable called “list-item-that-was-chosen” will have this value: “List.child”+random-number, so it will say “List.child8”
- I want to know the value of the random child that was chosen, so I want to use the value of the variable called “list-item-that-was-chosen”, like this:
GlobalVariable(GlobalVariable(list-item-that-was-chosen))
I need help with step 4.
Step 4 should become this:
GlobalVariable(List.child8)
How do I retrieve the value of the random child that was chosen?