Page 1 of 1

Deleting cards of stack

Posted: Wed Oct 05, 2022 10:10 am
by kresten
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

Re: Deleting cards of stack

Posted: Wed Oct 05, 2022 10:35 am
by Klaus
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

Re: Deleting cards of stack

Posted: Wed Oct 05, 2022 10:46 am
by richmond62
-

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 5067 times

Re: Deleting cards of stack

Posted: Wed Oct 05, 2022 11:33 am
by Klaus
It might be a clever idea to actually count up the variable KOUNT! 8)

Re: Deleting cards of stack

Posted: Wed Oct 05, 2022 11:42 am
by richmond62
It might be a clever idea to actually count up the variable KOUNT!
LOL 8)

Just getting into my second cup of coffee.

Re: Deleting cards of stack

Posted: Wed Oct 05, 2022 1:15 pm
by stam
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?

Re: Deleting cards of stack

Posted: Wed Oct 05, 2022 5:12 pm
by dunbarx
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

Re: Deleting cards of stack

Posted: Wed Oct 05, 2022 6:05 pm
by Klaus
Will move this thread to the Beginners section.

Re: Deleting cards of stack

Posted: Thu Oct 06, 2022 10:06 am
by kresten
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