Page 1 of 1

Using Groups

Posted: Mon Jan 06, 2014 11:43 pm
by hands16
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!!

Re: Using Groups

Posted: Tue Jan 07, 2014 12:30 am
by dunbarx
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.

Re: Using Groups

Posted: Tue Jan 07, 2014 12:34 am
by jmburnod
Hi,

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

Best regards
Jean-Marc

Re: Using Groups

Posted: Tue Jan 07, 2014 12:51 am
by hands16
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.

Re: Using Groups

Posted: Tue Jan 07, 2014 2:31 am
by dunbarx
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

Re: Using Groups

Posted: Tue Jan 07, 2014 3:03 am
by dunbarx
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

Re: Using Groups

Posted: Tue Jan 07, 2014 2:17 pm
by Klaus
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

Re: Using Groups

Posted: Tue Jan 07, 2014 3:40 pm
by dunbarx
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

Re: Using Groups

Posted: Tue Jan 07, 2014 3:51 pm
by Klaus
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

Re: Using Groups

Posted: Tue Jan 07, 2014 4:04 pm
by FourthWorld
@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.