Deleting cards of 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
kresten
Posts: 153
Joined: Tue Sep 30, 2008 3:01 pm
Location: Copenhagen
Contact:

Deleting cards of stack

Post by kresten » Wed Oct 05, 2022 10:10 am

Examining my live-code designed Diary on my Mac BookPro i understood, that the central substack (of daycards) is saving the previous daycard the moment a new daycard is produced. Presently the result is an accumulation of 2070 daycards !!! As the content anyhow is added to a html file (through which parsings for words or pictograms can be done) the accumulation of daycard is actually superfluos.
I have a menu which permits the deletion of a single card. But I have to understand how to script the deletion of e.g. 500 cards,
manually or from a button or a menupoint. Could You suggest how, maybe just like "delete card 1 to 500 of this stack” ?
Hopefully
Kresten

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Deleting cards of stack

Post by Klaus » Wed Oct 05, 2022 10:35 am

Dag kresten,

yes, but you need a loop to do so:

Code: Select all

...  
lock messages
repeat with i = 500 down to 1
      delete cd i
end repeat
unlock messages
...
Best

Klaus

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9386
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Deleting cards of stack

Post by richmond62 » Wed Oct 05, 2022 10:46 am

-

Code: Select all

on mouseUp
   put  1 into KOUNT
   repeat until KOUNT > 20
      delete the second card of stack "Multi-Card Delete"
      add 1 to KOUNT
      end repeat
   go last
end mouseUp

Code corrected as klaus caught me by the short-and-curlies. 8)
-
SShot 2022-10-05 at 12.45.34.png
SShot 2022-10-05 at 12.45.34.png (11.7 KiB) Viewed 3650 times
Attachments
Multi-Card Delete.livecode.zip
Corrected stack.
(1.16 KiB) Downloaded 56 times
Last edited by richmond62 on Wed Oct 05, 2022 11:44 am, edited 1 time in total.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Deleting cards of stack

Post by Klaus » Wed Oct 05, 2022 11:33 am

It might be a clever idea to actually count up the variable KOUNT! 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9386
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Deleting cards of stack

Post by richmond62 » Wed Oct 05, 2022 11:42 am

It might be a clever idea to actually count up the variable KOUNT!
LOL 8)

Just getting into my second cup of coffee.

stam
Posts: 2682
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Deleting cards of stack

Post by stam » Wed Oct 05, 2022 1:15 pm

Rather than using individual cards to store data (and hence having to delete them etc, why not just have a single card and a data source (eg text file, database etc) that updates the one card?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9662
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Deleting cards of stack

Post by dunbarx » Wed Oct 05, 2022 5:12 pm

why not just have a single card
I am so with Stam on this.

Hypercard could navigate many thousands of cards without issue. But LC starts to slow noticeably after only a few thousand cards, and that in and of itself is a good reason NOT to store data that way. Never mind the messy task of cleaning up after a while.

And you do not have to use an external file. Know that there is no limit to the amount of data that a single card can contain, entirely without clutter. Storing the information on old cards can be effected in several different ways, custom properties being my favorite. You would write a simple handler to load the entire contents of a dayCard and store it. You can retrieve it at any time, or not, with another very simple handler.

Do you see? A single card is a template that simply displays the many suites of data stored somewhere within the card (or stack).

Navigation between "cards" is just as simple and just as transparent as moving from one card to another. To "go" to the "card" of a week ago, you just reload that card's data. You will never notice the difference. except that reloading a card from four years ago will take the same time as yesterday's.

So don't ever delete a card again, store them all.

Craig

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Deleting cards of stack

Post by Klaus » Wed Oct 05, 2022 6:05 pm

Will move this thread to the Beginners section.

kresten
Posts: 153
Joined: Tue Sep 30, 2008 3:01 pm
Location: Copenhagen
Contact:

Re: Deleting cards of stack

Post by kresten » Thu Oct 06, 2022 10:06 am

Thank you so much. I made a button with your script, and used it 4 times and ending with just 70 cards I moved it via extern hard disk to my new airbook , where it now opens without problems, in contrast to before where livecode rejected it.
Gratefully your Kresten

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”