• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Script Debugger Session Dump
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Script Debugger Session Dump


  • Subject: Script Debugger Session Dump
  • From: Christopher Stone <email@hidden>
  • Date: Mon, 20 May 2013 17:45:56 -0500

Hey Folks,

Sometimes I want to dump my Script Debugger session, so I can quit with safety and reboot or whatever.

This script saves aliases of all open script documents that have been saved to a new dated folder, and it saves the source of unsaved script documents into individual .applescript files in the same folder.  It then opens the dump-folder in the Finder for convenience.

The script is dependent upon the Satimage.osax.  At the moment I don't want to take the time to make a vanilla variant, but it wouldn't be difficult.

--
Best Regards,
Chris

-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2013-05-20 : 16:36
# dMod: 2013-05-20 : 17:08
# Appl: Script Debugger
# Task: Save Script Aliases & Unsaved Script Source to Saved-Session-Scripts folder.
# Libs: err.lib, find.lib, gen.lib (Irrelevant in posted script.)
# Osax: Satimage.osax
# Tags: @Applescript, @Script_Debugger, @Backup, @Dump, @Session
-------------------------------------------------------------------------------------------

try

  

  set unsavedFlag to false

  

  tell application "Script Debugger"
    set sdAppSuptFldr to (join (items 1 thru -3 of (splittext (templates folder as text) using ":")) using ":") & ":"
    set dumpFldr to sdAppSuptFldr & "Saved-Session-Scripts:"
    set scriptPathList to file spec of documents whose path contains "users/"
    set unsavedDocSrcL to source text of every document whose name starts with "Untitled"
    if unsavedDocSrcL ≠ {} then
      repeat with i in unsavedDocSrcL
        # Strip whitespace off top and bottom of src:
        set contents of i to cng("\\A\\s+|\\s+\\Z", "", contents of i) of me
      end repeat
      set unsavedFlag to true
    end if
  end tell

  

  set _date to strftime (get current date) into "%Y.%m.%d.%H%M%S"
  set newFldrPathH to (dumpFldr & "Session_Dump_" & _date) & ":"

  

  do shell script "mkdir -p " & (quoted form of (POSIX path of newFldrPathH))

  

  set writeToAlias to alias newFldrPathH
  tell application "Finder"
    repeat with i in scriptPathList
      make new alias file at writeToAlias to (i)
    end repeat
    open alias dumpFldr
  end tell

  

  if unsavedFlag then
    repeat with i from 1 to length of unsavedDocSrcL
      writetext (item i of unsavedDocSrcL) to file ((newFldrPathH as text) & "Unsaved_Script_Src_" & i & ".applescript")
    end repeat
  end if

  

on error e number n
  stdErr(e, n, true, true) of me
end try

-------------------------------------------------------------------------------------------
on cng(findText, changeText, srcData)
  change findText into changeText in srcData with regexp without case sensitive
end cng
-------------------------------------------------------------------------------------------
on stdErr(e, n, beepFlg, ddFlg)
  set e to e & return & return & "Num: " & n
  if beepFlg = true then
    beep
  end if
  if ddFlg = true then
    tell me
      set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
    end tell
    if button returned of dDlg = "Copy" then set the clipboard to e
  else
    return e
  end if
end stdErr
-------------------------------------------------------------------------------------------



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: InDesign Separations
  • Next by Date: Applescript in the future
  • Previous by thread: Re: Setting spotlight comments
  • Next by thread: Applescript in the future
  • Index(es):
    • Date
    • Thread