home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / FileMover / Dopus5 / scx-do51.lha / arexx / UnDMS.dopus5 < prev   
Encoding:
Text File  |  1995-04-06  |  2.5 KB  |  95 lines

  1. /*
  2.   $VER: UnDMS.dopus5 1.0 (31.3.95)
  3.   Written by Edmund Vermeulen.
  4.   ARexx script for DOpus 5 to unpack a dms file with progress indication.
  5.   Call as 'REXX:UnDMS.dopus5 {f} {p}'.
  6. */
  7.  
  8. options results
  9.  
  10. lf='0a'x  /* ascii code for linefeed */
  11.  
  12. parse arg '"' dmsfile '"' portname .
  13.  
  14. if portname~=='' then
  15.    address value portname
  16.  
  17. if upper(right(dmsfile,4))~='.DMS' then do
  18.    dopus request '"Not a DMS disk archive file!" OK'
  19.    exit
  20.    end
  21.  
  22. cuthere=lastpos('/',dmsfile)
  23. if cuthere=0 then
  24.    cuthere=pos(':',dmsfile)
  25. dmsname="'"substr(dmsfile,cuthere+1)"'"
  26.  
  27. dopus request '"Please insert disk in drive and then select'lf'destination for' dmsname'." DF_0:|_RAD:|_Cancel'
  28.  
  29. select
  30.    when rc=1 then
  31.       dest='DF0:'
  32.    when rc=2 then
  33.       dest='RAD:'
  34.    otherwise
  35.       exit
  36.    end
  37.  
  38. lister new
  39. handle=result
  40.  
  41. lister set handle busy on
  42. lister set handle path dest
  43. lister set handle progress 80 'Unpacking' dmsname'...'
  44.  
  45. /* wow! some clever stuff here */
  46. address command 'Run >NIL: <NIL: DMS <NIL: >PIPE:dmsout WRITE' dmsfile 'TO' dest 'NOTEXT'
  47. address command 'Status >T:ProcessNo COMMAND DMS'
  48. call open('temp','T:ProcessNo','r')
  49. process=readln('temp')
  50. close('temp')
  51. address command 'Delete >NIL: T:ProcessNo QUIET'
  52.  
  53. nomessage=1
  54. errorreport=''
  55. buffer=''
  56. call open('dmsout','PIPE:dmsout','r')    /* output from DMS comes through PIPE: */
  57.  
  58. do until eof('dmsout')
  59.    buffer=buffer||readch('dmsout',25)    /* read portions of 25 characters */
  60.    here=verify(buffer,'0a0d'x,'m')    /* check for new lines */
  61.    if here>0 then do
  62.       line=left(buffer,here-1)        /* one whole line */
  63.       if nomessage&left(line,7)='No Disk' then do
  64.          lister set handle progress name 'Insert disk in' dest
  65.          nomessage=0
  66.          end
  67.       parse var line ' ' line        /* get rid of some ugly stuff */
  68.       buffer=substr(buffer,here+1)
  69.       if pos('ERROR',upper(line))>0 then do
  70.          errorreport=errorreport||lf||line
  71.          say '07'x            /* beep the display */
  72.          end
  73.       if pos('unPacking',line)>0 then do
  74.          track=right(line,2)
  75.          lister set handle progress count track+1
  76.          lister set handle progress name 'Track' track
  77.          lister query handle abort
  78.          if result then do
  79.             address command 'Break' process 'C'
  80.             lister set handle busy off
  81.             lister set handle title 'UnDMS aborted...'
  82.             exit
  83.             end
  84.          end
  85.       end
  86.    end
  87.  
  88. call close('dmsout')
  89.  
  90. if errorreport~=='' then
  91.    dopus request '"Error Report'||lf||errorreport'" OK'
  92.  
  93. lister set handle busy off
  94. lister read handle dest force
  95.