home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / Installer SDK 1.2.3 / Upgrader 1.2.3 & Engines / ASR 1.3.2 / AppleScript Examples / Example ASR Restore AScript < prev    next >
Encoding:
Text File  |  1998-02-17  |  1.6 KB  |  37 lines  |  [TEXT/ToyS]

  1. set tWhatToRestore to lastASitem(":", (path to me as string))
  2. set tWhereToRestore to choose folder with prompt "Select a volume and press 'Choose'"
  3.  
  4. launch application "Apple Software Restore"
  5. --NOTE! Launching an application from AppleScript is different than opening it with a
  6. --"Tell application" line. When you "launch" ASR 1.3.2 from AppleScript, this tells ASR
  7. --to enter "background" mode. This replaces the need for the "LaunchASR" OSAX
  8.  
  9. tell application "Apple Software Restore"
  10.     with timeout of 1000000 seconds
  11.         try
  12.             Restore tWhatToRestore to ¬
  13.                 tWhereToRestore placing in entire volume ¬
  14.                 preprocess erasing disk ¬
  15.                 copying everything ¬
  16.                 warning true ¬
  17.                 barber pole speed 10 with checksum, removing unwanted files and erasing on failure
  18.         on error tErrorMessage number tErrorNumber
  19.             display dialog ("Error: " & "[" & tErrorMessage & "]" & ", [" & tErrorNumber & "]")
  20.         end try
  21.     end timeout
  22.     quit
  23. end tell
  24. --Note on the first parameter to the 'Restore' command: If you pass in a pathname or alias, ASR
  25. --will assume it's a single image and restore it (if present). If you simply pass in a string 
  26. --(as in the example), ASR will look in the 'Configurations' folder for an image with that name.
  27. --If the 'Configurations' folder is not present, ASR will look in the same folder as itself
  28. --for an image with that name.
  29.  
  30. on lastASitem(delim, theText)
  31.     -- returns the portion of <theText> that follows the last <delim>
  32.     set theText to theText as string
  33.     if delim is in theText then
  34.         set theText to lastASitem(delim, (characters ((offset of delim in theText) + 1) through (length of theText) of theText))
  35.     end if
  36.     return theText
  37. end lastASitem