Getting the value of a variable

Hi guys,

I have stored several variables as coordinates. Depending on where the user presses the screen, I want to execute a piece of code.

For instance I have "var1x = 250" and "var1y = 300". I have about 40 of these variables.

Later in code when the user presses a certain image, I build a string that creates the variable name. For example "wk_x = var .. wk_num .. x"

When I print wk_x to the terminal, it correctly gives "var1x". How do I make wk_x actually give 250 rather than the string value. Is there a "value" type operator?

Thanks

Adrian

I had tried tonumber() but it only returns nil. I am not trying to convert wk_x to a number, I am trying to convert the variable name contained within the variable to a number. wk_x could be var1x, var2x, var3x, etc...

Adrian

@Adrian,
I will refer you to this article http://howto.oz-apps.com/2011/09/referencing-multiple-objects-of-same.html

it is to do with arrays... sometimes we forget that we can just use arrays rather than have such complicated requirements.

1
2
3
varx = {}
varx[1] = 200
varx[2] = 250
views:1514 update:2011/10/25 9:10:48
corona forums © 2003-2011