local snCardNum, snObjNum

on mouseUp
   local  lcScripts, lcObjScripts , cFile, lcTemp, lcStart, lcEnd
   
   put 0 into snCardNum
   put 0 into snObjNum
   
   
   put the "START STACK SCRIPT>>>>>>>>>>>" & the name of this stack & "<<<<<<<<<<<<<<<" & return into lcScripts
   put the script of this stack after lcScripts
   put the "END STACK SCRIPT >>>>>>>>>>>" & the name of this stack & "<<<<<<<<<<<<<<<" & return & return  after  lcScripts
   
   repeat for the number of cards of this stack
      add one to snCardNum
      put  return & return & "START CARD =======================>" & the name of card snCardNum & return & return into lcStart
      put the script of card snCardNum into lcTemp
      put ObjectScripts() after lcObjScripts
      put "END CARD =======================>" & the name of card snCardNum  & return into lcEnd
      
      put lcStart after lcScripts
      if lcTemp is not empty then
         put return & lcTemp  & return after lcScripts
      end if
      if lcObjScripts is not empty then
         put lcObjScripts after lcScripts
      end if
      put return & lcEnd after lcScripts
      
      put 0 into snObJNum
   end repeat
   
   put lcScripts
   
   set the defaultfolder to specialfolderpath("desktop")
   put lcScripts into url("file:temp.txt")
   
   launch "c:/windows/notepad.exe" && "temp.txt"
   
end mouseUp

Function ObjectScripts
   local lcObjScripts, lcObjName, lcTemp
   
   repeat for the number of controls of card snCardNum 
      
      add one to snObjNum
      put empty into lcTemp
      
      put the name of control snObjNum of card snCardNum into lcObjName
      
      -- Don't put the script of the Button with this script in
      if the name of me is lcObjName then
         next repeat
      end if
      
      put the script of control snObjNum of card snCardNum into  lcTemp
      if lcTemp is not empty then
         put return after lcTemp
         put return & return & "---- OBJECT/CONTROL ------------------------>"  & lcObjName  & return  before lcTemp
         put lcTemp after lcObjScripts
      end if
      
      put lcTemp after lcObjScripts
      
   end repeat
   
   return lcObjScripts
   
end ObjectScripts
