Deleting all cards from a stack

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
MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Deleting all cards from a stack

Post by MaxV » Sun Jul 28, 2013 10:53 am

Hi,
I really don't realize how to deleting all cards from a stack, i tried to put on with Stack script:

Code: Select all

delete all cards
but it doesn't work
Then I tried with

Code: Select all

   put the number of cards into temp
   repeat with temp2 = 1 to temp     
      delete card temp2
   end repeat
It starts to delete cards, but it randomly stops with this error: can't find card

How do you delete all cards from a stack?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Deleting all cards from a stack

Post by MaxV » Sun Jul 28, 2013 11:00 am

SOLVED, it must be appllied reverse way:

Code: Select all

put the number of cards into temp
   repeat with temp2 = temp down to 1
      delete card temp2
   end repeat
Please note that when the last card is deleted, LiveCode automatically create a new one. It seems that a stack without a card can't exist.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Deleting all cards from a stack

Post by Klaus » Sun Jul 28, 2013 11:28 am

MaxV wrote:SOLVED, it must be appllied reverse way:
...
repeat with temp2 = temp down to 1
...
8-)
MaxV wrote:...It seems that a stack without a card can't exist.
Exactly! If there are controls on the "last" card, they will be completely deleted, which is NOT UNDOABLE!


Best

Klaus

Post Reply