home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / FileMover / Dopus5 / DC-OP55B.LZX / Opus5 / arexx / FIDEdit.dopus5 < prev    next >
Encoding:
Text File  |  1996-07-20  |  4.0 KB  |  161 lines

  1. /*
  2.   $VER: FIDEdit.dopus5 1.0 (19.7.96)
  3.   Written by Edmund Vermeulen (edmundv@grafix.xs4all.nl).
  4.  
  5.   ARexx script for Directory Opus 5 to edit File IDs in archives.
  6.  
  7.   Function : ARexx      DOpus5:ARexx/FIDEdit.dopus5 {Qp}
  8. */
  9.  
  10. editor='TTX WAIT'    /* for TurboText */
  11.  
  12. /*
  13. editor='Ed'        /* for AmigaDOS Ed */
  14. editor='CED -keepio'    /* for CygnusED 3.5 */
  15. */
  16.  
  17.  
  18. parse arg portname .
  19.  
  20. if portname='' then
  21.    portname='DOPUS.1'
  22. address value portname
  23.  
  24. options results
  25. options failat 21
  26.  
  27. lf='0a'x
  28.  
  29. lister query source
  30. if rc>0 then
  31.    exit
  32. parse var result handle .
  33.  
  34. lister set handle busy on
  35.  
  36. lister query handle path
  37. srcpath=result
  38.  
  39. lister query handle selfiles stem files.
  40.  
  41. lister set handle progress files.count 'FIDEdit'
  42.  
  43. if exists('T:FILE_ID.DIZ') then do
  44.    command wait protect name 'T:FILE_ID.DIZ' set 'RWD'
  45.    address command 'Delete >NIL: T:FILE_ID.DIZ QUIET'
  46.    end
  47.  
  48. do i=0 to files.count-1
  49.    lister query handle abort
  50.    if result then
  51.       signal quitit
  52.  
  53.    lister set handle progress count i+1
  54.    lister set handle progress name files.i
  55.    lister query handle entry files.i stem fileinfo.
  56.  
  57.    thisfile='"'srcpath||fileinfo.name'"'
  58.    ext=reverse(fileinfo.name)
  59.    parse var ext ext '.'
  60.    ext=upper(reverse(ext))
  61.  
  62.    select
  63.       when ext='LHA'|ext='LZH'|ext='RUN' then
  64.          address command 'LhA >NIL: e -q -x0 -Qw -Qo' thisfile 'T: FILE_ID.DIZ'
  65.       when ext='LZX' then
  66.          address command 'LZX >NIL: x' thisfile 'FILE_ID.DIZ T:'
  67.       when ext='DMS' then
  68.          address command 'DMSDescript >NIL: x T:FILE_ID.DIZ' thisfile
  69.       otherwise
  70.          nop
  71.       end
  72.  
  73.    command wait protect name 'T:FILE_ID.DIZ' set 'RWD'
  74.  
  75.    repack=0
  76.    do forever
  77.       fid=''
  78.       illegal=0
  79.       if open('fileid','T:FILE_ID.DIZ','r') then do
  80.          lines=0
  81.          do while ~eof('fileid') & lines<=12
  82.             idline=compress(readln('fileid'),'"'||'0d1a'x)
  83.             if ~(idline=='' & eof('fileid')) then do
  84.                lines=lines+1
  85.                if lines>12 then do
  86.                   fid=fid||lf||lf||'[> 12 lines]'
  87.                   illegal=1
  88.                   end
  89.                else do
  90.                   if length(idline)>44 then do
  91.                      idline=left(idline,44)'... [> 44 chars]'
  92.                      illegal=1
  93.                      end
  94.                   if fid~=='' then
  95.                      fid=fid||lf
  96.                   fid=fid||idline
  97.                   end
  98.                end
  99.             end
  100.          call close('fileid')
  101.          end
  102.       else
  103.          fid='No File ID found!'
  104.  
  105.       if repack then
  106.          dopus request '"'fid'" Repack|Edit|Cancel|Abort'
  107.       else
  108.          dopus request '"'fid'" Next|Edit|Abort'
  109.       select
  110.          when rc=0 then
  111.             signal quitit
  112.          when rc=1 then do
  113.             if illegal then do
  114.                dopus request '"Illegal File ID!" Back|Cancel'
  115.                if rc=0 then
  116.                   leave
  117.                end
  118.             else
  119.                leave            
  120.             end
  121.          when rc=2 then do
  122.             address command editor 'T:FILE_ID.DIZ'
  123.             dopus front
  124.             repack=1
  125.             end
  126.          when rc=3 then do
  127.             repack=0
  128.             leave
  129.             end
  130.          end
  131.       end
  132.  
  133.    if repack & ~illegal then do
  134.       address command 'Rename T:File_Id.Diz T:FILE_ID.DIZ QUIET'
  135.       command protect name '"T:FILE_ID.DIZ"' clear 'E'
  136.       select
  137.          when ext='LHA'|ext='LZH'|ext='RUN' then
  138.             address command 'LhA >NIL: r -q -x0 -Qw -Qo' thisfile 'T:FILE_ID.DIZ'
  139.          when ext='LZX' then
  140.             address command 'LZX >NIL: r' thisfile 'T:FILE_ID.DIZ'
  141.          when ext='DMS' then do
  142.             address command 'DMSDescript >NIL: d' thisfile
  143.             address command 'DMSDescript >NIL: a T:FILE_ID.DIZ' thisfile
  144.             end
  145.          otherwise
  146.             nop
  147.          end
  148.       end
  149.          
  150.    address command 'Delete >NIL: T:FILE_ID.DIZ QUIET'
  151.    lister select handle '"'fileinfo.name'"' off
  152.    end
  153.  
  154.  
  155. quitit:
  156.  
  157.    lister clear handle progress
  158.    lister refresh handle full
  159.    lister set handle busy off
  160.    address command 'Delete >NIL: T:FILE_ID.DIZ QUIET'
  161.