Deleting cards of stack
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Deleting cards of stack
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
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
Dag kresten,
yes, but you need a loop to do so:
Best
Klaus
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
...
Klaus
-
- Livecode Opensource Backer
- Posts: 9445
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Deleting cards of stack
-
Code corrected as klaus caught me by the short-and-curlies.
-
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
-
- Attachments
-
- Multi-Card Delete.livecode.zip
- Corrected stack.
- (1.16 KiB) Downloaded 61 times
Last edited by richmond62 on Wed Oct 05, 2022 11:44 am, edited 1 time in total.
Re: Deleting cards of stack
It might be a clever idea to actually count up the variable KOUNT!
-
- Livecode Opensource Backer
- Posts: 9445
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Deleting cards of stack
LOLIt might be a clever idea to actually count up the variable KOUNT!
Just getting into my second cup of coffee.
Re: Deleting cards of stack
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?
-
- VIP Livecode Opensource Backer
- Posts: 9731
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Deleting cards of stack
I am so with Stam on this.why not just have a single card
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
Will move this thread to the Beginners section.
Re: Deleting cards of stack
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
Gratefully your Kresten