Deleting the contents of a group using code

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
andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Deleting the contents of a group using code

Post by andyh1234 » Thu May 14, 2020 12:41 pm

I think this is a beginner level question that I'm really struggling with.

All I want to do is empty a group in code so I can repopulate it.

I have a 'complex (to me)' script that takes a template group and works through a loop to add instances of it into the master group. The problem is when I want to add an item I would just like to clear the master group and then re-run the build to repopulate it with the latest data.

Deleting all items in a group sounds simple but for the life of me I cannot work out the code to do it, all I want is the group I have called

group "grpScroller"

stays on the card, and it is empty read to take new data.

All the data I add to the group also group if that makes sense, I copy a template group into grpscroller, all that is working great, I just can't work out how to wipe the group clean ready for a new set of data.

Should be easy but I'm stuck.

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

Re: Deleting the contents of a group using code

Post by Klaus » Thu May 14, 2020 12:56 pm

Hi Andy,

this will do the trick:

Code: Select all

on mouseUp
   put the num of controls of grp 1 into tNum
   repeat with i = tNum down to 1
      delete control i of grp 1
   end repeat
end mouseUp
Best

Klaus

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Re: Deleting the contents of a group using code

Post by andyh1234 » Thu May 14, 2020 1:14 pm

Thank you!!!!

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”