home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Programming / Dialog Director 0.6 / Res Utils Examples / Copy Res File.as next >
Encoding:
Text File  |  1996-12-02  |  1.1 KB  |  36 lines  |  [TEXT/ToyS]

  1. on run
  2.     set r to {}
  3.     set srcFile to choose file with prompt "Choose a res file:"
  4.     set dstFile to new file with prompt "Copy to:" default name "Output.rsrc"
  5.     set r2 to 0
  6.     set rf to res open srcFile
  7.     try
  8.         try
  9.             res create dstFile creator type "RSED" file type "rsrc"
  10.         on error number errNum
  11.             if errNum = -48 then
  12.                 tell application "Finder" to delete dstFile
  13.                 res create dstFile creator type "RSED" file type "rsrc"
  14.             end if
  15.         end try
  16.         set r2 to res open dstFile with write permission
  17.         
  18.         set rTypesCount to res count types rf
  19.         repeat with i from 1 to rTypesCount
  20.             set rType to res get type rf index i
  21.             set rCount to res count rf type rType
  22.             --set r to r & [rType as type class, rCount]
  23.             set r to r & [rType, rCount]
  24.             repeat with j from 1 to rCount
  25.                 res put r2 type rType id 1000 + j data (res get rf type rType index j)
  26.             end repeat
  27.         end repeat
  28.     on error errText number errNum from offendingObjectVariable
  29.         if r2 ≠ 0 then res close r2
  30.         res close rf
  31.         error errText number errNum from offendingObjectVariable
  32.     end try
  33.     res close r2
  34.     res close rf
  35.     r
  36. end run