Repeat loop testing

barryb at libero.it barryb at libero.it
Sun May 17 11:52:44 EDT 2009


On a single card I aim to have the following repeat structure called from 
several buttons.
Objects with a certain word in the name should move with 
respect to many others. 

Each object has custom properties which determine the 
locs it should move to, ending up at a unique point - it's 'berth'

 on mouseUp

    repeat with x = 1 to the number of images of this card
      if "ball" is 
not in the name of image x then
       next repeat
        else 
    set the 
layer of image x to bottom
    wait for 3 ticks
    set the loc of image x to 
the harbour of image x
    set the layer of image x to top
    wait for 3 ticks

   move image x to the berth of image x
   end if
end repeat
end mouseUp

For 
test purposes, I have set up a simple stack with just 4 objects represented by 

images of billiard balls.

The red, green and yellow  balls only should:
1- go 
to bottom layer
2- move to CP harbour
3- return to top layer
4- move to CP 
berth.
---------------------------
Things that have happened on a single 
mouseUp:

1 ball at random, goes bottom then goes to the harbour loc but stays 
there at bottom;
another does the same but comes to top; the third goes 
directly to its berth loc 
without leaving the top layer.
A blue ball that does 
not have "ball" in it's name should not move - but if it has the 
same 
custprops, it does!

At present I repeatedly get this error:
...........
Type	
Object: coordinate is not a point
Object	Button
Line	set the loc of image x to 
the harbour of image x
Hint	button id 1009 of card id 1002 of stack "C:
/Programmi/Revolution Studio/ballteststack.rev"
...........
However, if I close 
the script errors and clic again, the loop will step through and 
each ball 
will eventually go to the CP which "is not a point".

For the prognosis of my 
mental health, if this question does not already demonstrate 
unrepairable 
damage, please take a look at the stack 'ballteststack' available on the 
old 
revOnline under 'BarryB'

Somebody here will probably say this question should 
have required only 2 lines :-)
I bet the answer does!

Thanks in advance
Barry



More information about the use-livecode mailing list