Can one place variables in arrays could anyone tell me please
Variables in arrays?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Variables in arrays?
Hi, I haven't read much about arrays in Rev yet, including the so-called "3D" arrays in 3.0, but a thought came to me:
Can one place variables in arrays could anyone tell me please
Can one place variables in arrays could anyone tell me please
Not sure what you mean... 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?
And if subsequently tVar changes to 2, then when someone evaluates tArr[1] the returned value also is 2?
You can do the "pass by reference" thing in a function, but I am not aware of a similar approach with an array.
You could, of course put the variable name into the array and then "do" a command which will be evaluated before action, thus:Is that anything like what you're trying to determine?
Assuming it's what you're describing, any of the forum heavyweights know a better technique?
put 1 into tVar
put <a reference to tVar> into tArr[1]
So that if someone evaluates tArr[1] the returned value is 1?
And if subsequently tVar changes to 2, then when someone evaluates tArr[1] the returned value also is 2?
You can do the "pass by reference" thing in a function, but I am not aware of a similar approach with an array.
You could, of course put the variable name into the array and then "do" a command which will be evaluated before action, thus:
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" & quoteAssuming it's what you're describing, any of the forum heavyweights know a better technique?
Hi SparkOut
Thanks again for your help.

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?
Thanks again for your help.
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.
See, it takes a proper forum heavyweight to help: http://forums.runrev.com/phpBB2/viewtop ... 2813#12813
Try
Thanks Jan!
Try
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 mouseUpI'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
It's great that whatever level we're at we all chip in (and there's not much punching goes on in the Forum
Thank you for that info on arrays. I'm bound to revisit this thread when I delve boldly into multi-dimensional arrays at a later date. (I'm still wrangling with custom properties which I'm sort of getting the hang of, although I expect I'll be putting another question about it soon!)
