Hi
I have variables in my code
H1[mcount]
H2[mcount]
H3[mcount]
the 1,2,3 is set using a counter
How do I programmatically pass the name of H1, H2 and H3 as say a variable myvar
so my code would appear
myvar[mcount] where myvar is set to H1 , H2 or H3
I have tried
put 1 into Fcount
put H & Fcount into myvar
when I use
answer myvar[mcount] it return the right value but if I use
answer H1[mcount] it returns empty
thx
passing in a variable name
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 10044
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: passing in a variable name
Whenever you have a number of variables whose names can't be known in advance it's a good case for arrays. Since you're already using arrays, it's even easier, just add another level to it, e.g.:
Code: Select all
put "H1" into tFirstLevelKey
put "mcount" into tSecondLevelKey
put "SomeValue" into tArray[ tFirstLevelKey][tSecondLevelKey]
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn