and a new GM is born for everyone...

MisterX b.xavier at internet.lu
Sat Apr 16 07:23:45 EDT 2005


Here's the resizestack script I use in TAOO

global xos

on resizestack
  local gcount
  put the short id of the defaultstack into stkID 
  -- to be verified if ok for both palettes and stacks (the topstack).
  put the number of controls in stack id stkID into ccount
  repeat with x = 1 to ccount
     
    get the short id of control x of stack stkID
    	 get xos["haveresizescript",stkID,x]
    if it is empty then
      get "on doresize" is in script of control x 
      put it into xos["haveresizescript",stkID,x]
    end if
    if it then
      try
        send "doresize" to control x
      end try
    end if
  end repeat
  pass resizestack
end resizestack

cheers
Xavier


> -----Original Message-----
> From: David Burgun [mailto:dburgun at dsl.pipex.com] 
> Sent: Saturday, April 16, 2005 12:15
> To: x at monsieurx.com
> Subject: RE: and a new GM is born for everyone...
> 
> Opps! Spotted a typeo!
> 
> --
> --  The in the Script of each Control
> --
> on MGMInitialize
> if the script of me contains "MGMDoResize" then
>     set cpResizeHandler to "MGMDoResize"
> else
>     set cpResizeHandler to empty  
> --**********CHANGED********** end if end
> 
> Cheers
> Dave
> 
> >One difference is instead of using the custom prop, i just 
> use a global 
> >array. minimizes stack size...
> >
> >the <this> and </this ;> where regarding the line put "this" 
> into your ...
> >
> >object talk ;)
> >
> >But nice example of collaborative scripting ;)
> >
> >cheers
> >Xavier
> >
> >>  -----Original Message-----
> >>  From: David Burgun [mailto:dburgun at dsl.pipex.com]
> >>  Sent: Saturday, April 16, 2005 11:17
> >>  To: x at monsieurx.com; How to use Revolution
> >>  Subject: Re: and a new GM is born for everyone...
> >>
> >>  Hi,
> >>
> >>  >The number of controls might require this in terms of speed  
> >> (querying  >if the script contains is long) - the agent 
> also uses a  
> >> cached index to  >speed this up in the repeat loop though. I have 
> >> also found  that I use  >mostly templates and thus limit 
> the repeat 
> >> search to just groups so  >scripts are more dedicated or localized.
> >>
> >>  I handn't thought of looking in the script to see if a  
> handler or 
> >> function or whatever existed. Wow! That's so  powerfull. 
> Of course, I 
> >> suppose someone *could* have already  of used that name, 
> so it might 
> >> be better to prefix it with  "MGM_" or something so that 
> it is less 
> >> likely to clash.
> >>
> >>  What are you worried about in terms of speed? If you said 
>  that the 
> >> "doresize" (or whatever) was always near the start  of the script 
> >> then would this make a difference?
> >>
> >>  I do something similar to this in a Generic Arrow Resize  
> Object I 
> >> have created. The way I am trying to do it is to  have an 
> >> Initialization Handler in each control that sets a  
> CustomProperty, 
> >> in this case we could call it  cpResizeHandler. The script 
> would look 
> >> something like this:
> >>
> >>
> >>  --
> >>  --  Called from openScipt or openCard
> >>  --
> >>  on Initialize()
> >>  put the number of controls into controlsmax
> >>     repeat with x = 1 to controlsmax
> >>         if "MGMInitianize" is in the script of control x then
> >>          send "MGMInitialize" to control x
> >>     end repeat
> >>  end
> >>
> >  > --
> >>  --  The in the Script of each Control
> >>  --
> >>  on MGMInitialize
> >>  if the script of me contains "MGMDoResize" then
> >>     set cpResizeHandler to "MGMDoResize"
> >>  else
> >>     set cpResizeHandler to "MGMDoResize"
> >>  end if
> >>  end
> >  >
> >>
> >>  Then do the following in the resize stack command:
> >>
> >>  put this into your stack script...
> >>  <this>
> >>  on resizeStack
> >>     MagicGM
> >>     pass resizestack -- if you dont pass, the RevErrorDialog
> >>  (RED) or other stacks might not resize correctly although 
> the  RED 
> >> still doesnt yet...
> >>  end resizeStack
> >>
> >>  on MagicGM
> >>     put the number of controls into controlsmax
> >>     repeat with x = 1 to controlsmax
> >>
> >>       if  the  cpResizeHandler of control x is not empty then
> >>         send the cpResizeHandler of control x
> >>       end if
> >>
> >>     end repeat
> >>  end MagicGM
> >>  </this ;>
> >>
> >>  (((***Question? What are <text> and </this ;> lines?***)))
> >>
> >>  This shoud speed it up at the expense of adding time to the  
> >> openStack or openCard command. The advantage is that you  
> don't have 
> >> to change the Stack/Card Script you add a new control.
> >>
> >>  One question though. If the control does not contain an  
> >> MGMInitialize handler, the Custom Property,  cpResizeHandler  will 
> >> not exist. Do I need a seperate test for his as in:
> >>
> >>  if exists  cpResizeHandler of control x then
> >>      if  the  cpResizeHandler of control x is not empty then
> >>         send the cpResizeHandler of control x
> >>       end if
> >>  end if
> >>
> >>  Any suggestions/comments greatly appreciated.
> >>
> >>  All the Best
> >>  Dave
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> 



More information about the use-livecode mailing list