Appropriate syntax for referencing objects in a looping structure?

Christopher Mitchell chrism at lumin.us
Sat Feb 21 08:42:39 EST 2004


Opie,

Thanks for the reply.  well, yes, you're right that this works - and I 
would have sworn I had tried it, but I guess the confusion stems from 
the fact that in my regular format I have to use the quotes.  So I must 
have just been loading the variable wrong earlier when I was doing it 
before I looked up 'quote' ... :/  It seems weird to not put quotes 
when it is in a variable and to put them when it is not.

The shorter way is the first thing I tried!  I promise!  must have been 
4am typos or something.  Thanks again!

Yours,
Chris, the Newbie
On Feb 21, 2004, at 6:15 AM, Ops wrote:

> Christopher,
>
> The name of your graphic pointer is:   pointer1      It's NOT 
> "pointer1" (with the double quotes).  In your lone set statement, the 
> quotes merely tell the engine that what's enclosed (withing the 
> quotes) should be treated (or looked upon) as a literal string and NOT 
> a variable/container...so in effect, your lone set statement actually 
> conveys to the engine the literal string:  pointer1
>
> In your repeat loop, you are telling the engine to look for a 
> container named "pointer1" instead of pointer1, and it does not find 
> it, and thus generates the error.  Change your repeat to:
>
>  repeat with i = 1 to 3
>      put "pointer" & i into tName
>      answer tName -- should now give you the right content: pointer1
>      set the angle of graphic tName to rotAngle
>    end repeat
>
> A shorter way to write the above would be:
>
> repeat with i = 1 to 3
> 	set the angle of graphic "pointer" & i to rotAngle
> end repeat
>
> Hope this was clear.
>
> Opie
>
> Christopher Mitchell wrote:
>
>> Howdy,
>> Another likely simple question for which the specific documentation 
>> does not seem readily available, or at least accessible.  Hopefully 
>> someday other newbies will benefit from all these syntax questions 
>> and you all won't tar and feather me just yet.  I feel like I've been 
>> spamming the list :/
>> -----
>> Ok, I've got a card with several graphic objects all named pointer1, 
>> pointer2, pointer3, etc.  I want a repeat script to change the angle 
>> property of each one of them.
>> The usual line that works outside the loop is, of course:
>> set the angle of graphic "pointer1" to rotAngle
>> The problem comes in getting the 'set' command to properly parse any 
>> of the content I'm throwing at it in order to make it work in the 
>> same way using the counter generated by a 'repeat with' loop, as 
>> follows:
>> repeat with i = 1 to 3
>>     put quote & "pointer" & i & quote into tName
>>     answer tName -- this is giving me the right content: "pointer1"
>>     set the angle of graphic tName to rotAngle  -- this line chokes 
>> with chunk error, no such object. hint: "pointer1"
>>   end repeat
>> As indicated by the comment, I put in the 'answer' just as a sanity 
>> check and the contents of tName at that point are exactly what I 
>> would type into the usual line; yet it tells me that there is a chunk 
>> error:no such object -  with the hint, ironically, as "pointer1"  ...
>> Is there some way i need to escape this variable tName when I put it 
>> in the 'set' statement in order to make it use the contents 
>> literally, exactly as if I had typed them in?  I've tried several 
>> combinations of using the quote constant and the '&' operator, but 
>> the 'set' command definitely does not like having those things in its 
>> strings anymore than moving it out into a variable.
>> Thanks,
>> Chris
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> http://lists.runrev.com/mailman/listinfo/use-revolution
> _______________________________________________
> 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