Getting a list of marked cards

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
ncmac
Posts: 31
Joined: Thu Apr 27, 2006 10:29 pm

Getting a list of marked cards

Post by ncmac » Sun Jun 10, 2012 6:08 pm

What does this return a list of the marked cards separated by many, many returns in the field and how can I get the list of marked cards as a list without the empty lines between each?

on mouseUp
repeat with n = 1 to the number of cards in this stack
if the mark of card n is true then put the short name of card n into item 1 of line n of card field "DataField"
end repeat
end mouseUp

Thanks!

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Getting a list of marked cards

Post by jmburnod » Sun Jun 10, 2012 6:25 pm

Hi ncmac,
separated by many, many returns in the field
Yes, one empty line = one no-mark card

This function return the list of the mark cards without empty line

Code: Select all

function TheMarkedCards
   put empty into rTheMarkedCards
   repeat with n = 1 to the number of cards in this stack
      if the mark of card n is true then put the short name of card n & return after rTheMarkedCards
   end repeat
   delete char -1 of rTheMarkedCards
   return rTheMarkedCards
end TheMarkedCards

You can use also :

Code: Select all

filter MyVariable without empty
Best regards

Jean-Marc
https://alternatic.ch

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Getting a list of marked cards

Post by sturgis » Sun Jun 10, 2012 6:35 pm

The following should work also since you can directly access using the "marked" keyword.

Code: Select all

on mouseUp
   repeat with n = 1 to the number of  marked cards in this stack
        put the short name of marked card n into item 1 line n of field "DataField"
   end repeat
end mouseUp

ncmac
Posts: 31
Joined: Thu Apr 27, 2006 10:29 pm

Re: Getting a list of marked cards

Post by ncmac » Sun Jun 10, 2012 7:14 pm

Thank you all very much!

Post Reply