Appropriate syntax for referencing objects in a looping structure?

Christopher Mitchell chrism at lumin.us
Sat Feb 21 04:59:13 EST 2004


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



More information about the use-livecode mailing list