Eureka! It's late, I'm tired and grouchy and I can't figure out a way to do this!

David Burgun dburgun at dsl.pipex.com
Fri Apr 7 09:30:45 EDT 2006


Hi All,

Ok, I finally found it! I knew I had the code there somewhere, it was  
on a PowerBook I had forgotten I had!

Got it working now, see below. It's really quite neat! A spot of  
recursion every now and then is good for the soul, check it out!

Oh, one thing that I could do with confirmation on, I am using the  
"long name", is this ok? Should I use the "long id" instead?

All the Best
Dave


------------------------------------------------------------------------ 
-
--
--  ISMInitializeGroup
--
------------------------------------------------------------------------ 
-
function ISMInitializeGroup theOwnerLongName
   local myIndex
   local myCount

   --
   --  Initialize all Groups that need to be Initialized
   --
   put the number of groups in theOwnerLongName into myCount

   repeat with myIndex = 1 to myCount
     if word 1 of the name of group myIndex of theOwnerLongName =  
"group" then
       if the long owner of group myIndex of theOwnerLongName =  
theOwnerLongName then
         get ISMDebugLogString(empty)
         get ISMDebugLogString(the name of group myIndex of  
theOwnerLongName)

--
--  Recurse thru the Container (Card or Group)
--     
      get ISMInitializeGroup(the long name of group myIndex of  
theOwnerLongName)
       end if
     end if
   end repeat

   --
   --  Initialize the Controls in this Group
   --
   repeat with myIndex = 1 to number of controls in theOwnerLongName
     if word 1 of the name of control myIndex of theOwnerLongName <>  
"group" then
       if the long owner of control myIndex of theOwnerLongName =  
theOwnerLongName then
         get ISMDebugLogString(the name of control myIndex of  
theOwnerLongName)
       end if
     end if
   end repeat

   return true
end ISMInitializeGroup


------------------------------------------------------------------------
--
--  ISMInitialzeObjects
--
------------------------------------------------------------------------ 
-
function XISMInitialzeObjects theStackLongName,theColdStartFlag
   local myCount
   local myHandlerString
   local myColdStartFlag
   local mySendString

   local myCardIndex
   local myGroupIndex
   local myControlIndex

   get ISMSetDebugMode(true,true)

   if theColdStartFlag = empty then
     put false into myColdStartFlag
   else
     put theColdStartFlag into myColdStartFlag
   end if

   get ISMDebugLogString("ISMInitialzeObejcts " & theStackLongName)
   get ISMDebugLogString(empty)


   put "on " & kInitializeObjectName into myHandlerString
   put kInitializeObjectName && myColdStartFlag into mySendString
   --
   --  Initialize the Stack
   --
   if the script of theStackLongName contains myHandlerString then
     --send mySendString to stack theStackLongName
   end if


   --
   --  Initialize all Cards
   --
   repeat with myCardIndex = 1 to the number of cards of  
theStackLongName
     get ISMDebugLogString(empty)
     get ISMDebugLogString(the name of card myCardIndex of  
theStackLongName)
     --
     --  Initialize all Groups and Controls in the current Card
     --	
get ISMInitializeGroup(the long name of card myCardIndex of  
theStackLongName)
   end repeat

   return true
end XISMInitialzeObjects





More information about the use-livecode mailing list