Code: Select all
on pdExportAllSubStacks
-- © 2019-1115 peterderks@t-online.de
-- A rather elegant Script to export all SubStacks of a MainStack to an own Folder
-- Use this free Software 'as is'.
put cr & cr into crr
play "Dialog"
answer file "Choose your MainStack containing the SubStacks to be exported, please:" with type "LiveCode Stacks|mc,rev,livecode|RSTK,MSTK" as sheet
put it into MyMainStack
if MyMainStack = "" then
play "NoOp"
exit to top
end if
put the SubStacks of stack MyMainStack into MySubStacks
if the Number of lines in MySubStacks = 0 then
play "Alarm"
answer MyMainStack & crr & "Your MainStack has no SubStacks …" as sheet
exit to top
end if
play "Dialog"
answer folder "Choose the Level of the Folder to hold the Stacks to be exported, please:" as sheet
put it into ExportLevel
if ExportLevel = "" then
play "NoOp"
exit to top
end if
put the Short Name of stack MyMainStack & "•SubStacks•" & (the Short System Date & "·" & the Short System Time) && "ƒ" & slash into ExportFolder
put ExportLevel & slash & ExportFolder into Export_Path
create folder Export_Path
repeat with ii = 1 to the Number of lines in MySubStacks
play "Count"
try
get line ii of MySubStacks
do "clone stack" && (quote & it & quote)
set the Name of it to (line ii of MySubStacks && "#")
save stack (line ii of MySubStacks && "#") as (Export_Path & line ii of MySubStacks)
wait 30 ticks
close stack (line ii of MySubStacks && "#")
catch ErrorX
play"Error"
answer ErrorX
end try
end repeat
set the DefaultFolder to Export_Path
play "Done"
wait until Sound() = Done
answer Export_Path & crr & "--------------------" & cr & the Files with "Done" as sheet
end pdExportAllSubStacks
Peter