Can one place variables in arrays could anyone tell me please

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Code: Select all
local t1,t2,tArr
put field "Field1" into tVar1
put field "Field2" into tVar2
put "tVar1" into tArr[1]
put "tVar2" into tArr[2]
do "put" && tArr[1] && "into field" && quote & "Field3" & quote
--this evaluates to
--put tVar1 into field "Field3" - so the result is the same
--but it's not reading a reference to the variable tVar1 from the array
--it's evaluating the name held in the array as part of the "do" string
--which is then actioned
do "put" && tArr[2] && "into field" && quote & "Field4" & quote
Yes, exactly what I meant, thank you.you want to say something like
put 1 into tVar
put <a reference to tVar> into tArr[1]
So that if someone evaluates tArr[1] the returned value is 1?
I hadn't thought that far, to be honest, i.e the variable changing and being "automatically" updated within the array if the variable changes; that interesting to know and useful for the future, I'm sure. As "pass by reference" is another of my sticking points I'm hoping I'll "get it" nearer the time.And if subsequently tVar changes to 2, then when someone evaluates tArr[1] the returned value also is 2?
Well SparkOut, if you consider yourself a middleweight I must be between a lightweight and a bantamweight!any of the forum heavyweights know a better technique?
Well, I, um, guess I'm sort of shocked. I never thought of myself as anything but "a contributor" - and never compared myself to Mark, Jan, Malte, Klaus, etc, etc. on the forum, and as for some of the "old-timers" on the use- and improve- lists, well... Anyway, I'm heartened and thankful.gyroscope wrote:Well SparkOut, if you consider yourself a middleweight I must be between a lightweight and a bantamweight!
Useful, definitely - but as of Rev 3.0 don't forget that there are multi-dimensional arrays available and you will also find this pertinent: http://www.runrev.com/newsletter/septem ... W57S445981 and find some of that older information superceded.gyroscope wrote:That's a useful link Phil, thanks.
Code: Select all
on mouseUp
local tArr, tVar
put "tVar" into tArr[1]
repeat with tVar = 1 to 100
put value(tArr[1]) & cr after field "fldResult"
end repeat
end mouseUp
I'm glad of that, SparkOut! Please don't underestimate your value. I was truly impressed by your coding in GyroButtonSortRevisited.rev.Anyway, I'm heartened