Using Groups

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
hands16
Posts: 17
Joined: Sat Oct 19, 2013 2:23 am

Using Groups

Post by hands16 » Mon Jan 06, 2014 11:43 pm

Hi i was wondering if there is a way to place a group on all of the cards in a stack, instead of having to do it card by card. The stack was made before the group was created. Thank You!!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Using Groups

Post by dunbarx » Tue Jan 07, 2014 12:30 am

HI.

Sure. Look up the "place" command in the dictionary. Note that this can be scripted, so if you have hundreds of cards this might be prudent. if you only have a handful, you might just do it manually.

Do you need help making a handler, if that is the way you need to go?

Craig Newman

EDIT.

Once you finish with this task, make sure to set the backgroundBehavior of the group to "true", so that in the future it will automatically place itself.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Using Groups

Post by jmburnod » Tue Jan 07, 2014 12:34 am

Hi,

You can also place a group on preopencard and remove it on closecard.

Best regards
Jean-Marc
https://alternatic.ch

hands16
Posts: 17
Joined: Sat Oct 19, 2013 2:23 am

Re: Using Groups

Post by hands16 » Tue Jan 07, 2014 12:51 am

well i know how to place the group on a single card, but is there a any way to place the group on all pre existing cards in my stack? like at the same time instead of doing it all manually one at a time.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Using Groups

Post by dunbarx » Tue Jan 07, 2014 2:31 am

Hmmm.

Apparently you do need help writing a handler that will do that. See my post two up.

If nobody else chimes in, I will be back after diinner.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Using Groups

Post by dunbarx » Tue Jan 07, 2014 3:03 am

Delicious.

Not sure where your group is. On the first card? Does not matter, but this places it on the next card and all subsequent.:

Code: Select all

on placeGroups
   repeat with y = the number of this card + 1 to the number of cards
      place group "yourGroup" onto cd y
   end repeat
end placeGroups
This might go into the stack script, and you can call it from the message box. Do you need to place it on earlier cards as well? Check this out and try that for yourself if you need. Remember what I said earlier about setting the backGroundBehavior...

Craig

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

Re: Using Groups

Post by Klaus » Tue Jan 07, 2014 2:17 pm

Hi Craig,

your script will throw an error! 8)
Better:

Code: Select all

on placeGroups
  repeat with y = the num of cards

    ## Check if group has already been placed:
    if there is grp "yourGroup" of cd y then
       next repeat
    end if

   ## You need to address the group with BG (background), if it is not on the current card!
   ## Or you get something like -> object not found: group "XYZ"

   ## Now place group onto cd:
   place BG "yourGroup" onto cd y
  end repeat
end placeGroups
Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Using Groups

Post by dunbarx » Tue Jan 07, 2014 3:40 pm

Klaus.

True, if the group is already placed on a distant card, since it is not permitted to place a group on a card that already contains that group.

But the OP asked how to automate placing a group onto subsequent cards. So my handler assumes too much, that all downstream cards do not have it? I guess so. Certainly a more robust handler would check that, as you say.

Craig

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

Re: Using Groups

Post by Klaus » Tue Jan 07, 2014 3:51 pm

Hi Craig,

since i only and always want the best for the beloved forum members,
I just wanted to avoid ANY possible and probably unexspected error dialog,
which will, and I speak out of experience, heavily irritate a new LC user :D


Best

Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Using Groups

Post by FourthWorld » Tue Jan 07, 2014 4:04 pm

@hands16: One thing that may be helpful to keep in mind while working in LiveCode is that everything in the IDE is done in the LiveCode language itself. The IDE scripts are complex, and as such not a good place to begin learning, but they can serve as good inspiration for any tools you might want to make to help automate your development - if the IDE can do it, you can too.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply