naming variables...
Dennis Brown
see3d at writeme.com
Wed May 4 12:15:53 EDT 2005
It is not a scripting error if you are following the Reference
Documentation supplied with Rev:
-----------------------------------------------
How do I create and use a numbered set of variables?
To easily create a set of variables with similar names (such as
"myVar1", "myVar2",...,"myVar20"), you can use the concatenation
operator &.
The following example shows how to use a set of variables named
"myVar1", "myVar2",...,"myVar20":
repeat with x = 1 to 20
put empty into ("myVar" & x)
end repeat
-----------------------------------------------'
Notice no mention of the do command. This is what tripped me up. I
entered a BZ for it: #2753
Dennis
On May 4, 2005, at 8:09 AM, Brian Yennie wrote:
> Yikes. I hope RunRev fixes this- I've seen it come up at least
> twice now on the list and it's an obvious scripting error.
> The solution is to use the "do" command. This is similar to the
> "eval" function you find in many other languages- basically you
> dynamically generate the line of code, and then "do" will execute
> it at runtime.
>
> ## "do" something
> repeat with x=1 to 20
> put ("fld a"&x&" into myVar"&x) into myCode
> ## myCode => the string "put fld a1 into myVar1"
> do myCode
> end repeat
>
> One cool sidenote- you can also use the "do" command to execute
> code from any other OSA scripting language installed if you are on
> MacOS, which usually means AppleScript.
>
> The other way to access "outside" code is to use shell() in order
> to run command-line commands, but now I'm straying...
>
> HTH,
> Brian
>
>
>> Hello all,
>>
>> how does it come that the simple "How do I create and use a
>> numbered set of variables?" example
>> does not work in 2.5.1 ?
>>
>>
>> I badly need to collect contents of flds into variables which are
>> used later in the script...
>>
>> repeat with x = 1 to 20
>> put fld ("a"&x) into ("myVar" & x)
>> end repeat
>>
>> --> returns error : bad destination ???
>>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list