New groups bugaBoo

Ken Ray kray at sonsothunder.com
Fri May 22 21:06:20 EDT 2009


 
> Yeah, apparently referencing the "last" group is still not reliable.  If you
> need to use this approach in your scripts, one option is to name the
> templateGroup, rather than using "last", as mentioned here:
> 
> http://www.nabble.com/Re%3A-am-I-right-with-select-and-group--p10972065.html

If you can create the group *first* before moving the objects into the
group, you can get the long id right after creation:

on mouseUp
   create group "Test"
   put it into tLongIDOfGroupIJustCreated
end mouseUp

But if you're trying to group selected objects, that doesn't work because
nothing comes back in "it" (or "the result" for that matter). Personally I
think the group command should return the long id of the group that was
created in the result...

The other way to do what you want is to trap the "newGroup" message either
in a frontscript or somewhere in the hierarchy that makes sense. Set a
property or global you can check and then move on. Something like:

<stack script>
global gLastGroupID

on newGroup
  put the long id of the targte into gLastGroupID
  pass newGroup
end newGroup


<button script>
global gLastGroupID

on mouseUp
  group grc 1 and grc 2 and grp B
  put gLastGroupID into tGroupID
  -- continue on using tGroupID
end mouseUp

NOTE: Make sure you PASS the newGroup message; I had Rev freeze on me if it
wasn't passed...

Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/





More information about the use-livecode mailing list