A rather elegant Script to export all SubStacks …

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
pderks
Posts: 58
Joined: Sat May 14, 2011 4:25 pm
Location: Krefeld • Deutschland

A rather elegant Script to export all SubStacks …

Post by pderks » Fri Nov 15, 2019 3:29 pm

Hi,

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
Best regards

Peter

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: A rather elegant Script to export all SubStacks …

Post by Klaus » Fri Nov 15, 2019 8:44 pm

Cool, thanks Peter! :D

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: A rather elegant Script to export all SubStacks …

Post by [-hh] » Fri Nov 15, 2019 11:28 pm

Cool.

Proverbs 27:2
Let another man praise thee, and not thine own mouth; a stranger, and not thine own lips.
Oder: Eigenlob stinkt! ;-)
shiftLock happens

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: A rather elegant Script to export all SubStacks …

Post by bogs » Fri Nov 15, 2019 11:41 pm

[-hh] wrote:
Fri Nov 15, 2019 11:28 pm
Proverbs 27:2
Let another man praise thee, and not thine own mouth; a stranger, and not thine own lips.
I'll be that guy ! Well, maybe not praise per se, but it is a nifty run at sub-stacking :P
Image

Post Reply

Return to “Talking LiveCode”