Page 1 of 1

repeat for each marked card i of this stack - error

Posted: Sat Apr 21, 2012 4:57 pm
by 3d-swiss
Hello

I like to visit all marked cards:
repeat for each marked card i of this stack
-- do something
end repeat
Please tell me, what's the correct first line.

Thanks, have a good weekend.

Re: repeat for each marked card i of this stack - error

Posted: Sat Apr 21, 2012 5:27 pm
by Mark
Hi,

Code: Select all

repeat with x = 1 to the number of cards
  if the marked of cd x then
    -- do something
  end if
end repeat
Kind regards,

Mark

Re: repeat for each marked card i of this stack - error

Posted: Sat Apr 21, 2012 5:29 pm
by Dixie
Hi...

Code: Select all

on mouseUp
   push card
   
   put the number of marked cards into cardCount
   repeat with count = 1 to cardCount
      go next marked card of this stack
      beep
      wait 1 second
   end repeat
   
   pop card
end mouseUp
be well

Dixie

Re: repeat for each marked card i of this stack - error

Posted: Sat Apr 21, 2012 5:35 pm
by 3d-swiss
Hi,

thanks for the answers. I like the second solution best, because it's faster :-)

BTW: It's confusing, that some objects can be used with 'repeat for each' and other not. :shock:

Re: repeat for each marked card i of this stack - error

Posted: Sat Apr 21, 2012 5:50 pm
by Mark
Hi,

Repeat for each is not for objects but for strings and arrays. Sometimes, strings are in objects, but they're still strings.

Yes, Dixie's script is actually better :-)

Kind regards,

Mark

Re: repeat for each marked card i of this stack - error

Posted: Sat Apr 21, 2012 6:04 pm
by Klaus
Hi guys,
Mark wrote:Repeat for each is not for objects but for strings and arrays.
yep, but I wish this would also work with cards and objects! 8)


Best

Klaus

Re: repeat for each marked card i of this stack - error

Posted: Thu May 17, 2012 5:02 pm
by dochawk
On the bright side, this thread was easy to find when I was looking for the same answer :)

Re: repeat for each marked card i of this stack - error

Posted: Thu May 17, 2012 6:24 pm
by dunbarx
A variation of the two perfectly good scripts you already have, but a little more compact.

repeat with y = 1 to the number of marked cards
set the yourProperty of btn "yourButton" of marked card y to newProperty -- just doing something on each marked card
end repeat

After all these, you should be more comfortable with both marked cards and repeat loops.

Craig Newman