home *** CD-ROM | disk | FTP | other *** search
- /*
- $VER: UnDMS.dopus5 2.1 (7.4.96)
- Written by Edmund Vermeulen (edmundv@grafix.xs4all.nl).
-
- ARexx script for Directory Opus 5.5 to unpack a DMS file to disk with
- progress indication.
-
- Call it from the 'Double-click' function of the 'DiskMasher archive'
- filetype.
-
- Function : ARexx DOpus5:ARexx/UnDMS.dopus5 {f} {Qp}
- Flags : Run asynchronously
- */
-
- devicecheck = 'DF_0 DF_1 DF_2 DF_3 _FF0'
- automount = '_RAD'
-
-
- parse arg '"' dmsfile '"' portname .
-
- if portname='' then
- portname='DOPUS.1'
- address value portname
-
- cuthere=lastpos('/',dmsfile)
- if cuthere=0 then
- cuthere=pos(':',dmsfile)
- dmsname="'"substr(dmsfile,cuthere+1)"'"
-
- options results
- lf='0a'x /* ascii code for linefeed */
-
- if ~show('l','rexxsupport.library') then
- call addlib('rexxsupport.library',0,-30) /* needed for showlist() and delete() */
-
- buttons=''
- n=0
-
- /* only show the devices that are really available */
- do while devicecheck~=''
- parse var devicecheck devbutton devicecheck
- dest=compress(devbutton,'_')
- if showlist('h',dest) then do
- n=n+1
- dest.n=dest
- buttons=buttons||devbutton'|'
- end
- end
-
- /* add automount devices */
- do while automount~=''
- n=n+1
- parse var automount devbutton automount
- dest.n=compress(devbutton,'_')
- buttons=buttons||devbutton'|'
- end
-
- dopus front
- dopus request '"Please insert disk in drive and then select'lf'destination for' dmsname'."' buttons'_Cancel'
- if rc=0 then
- exit
-
- devname=dest.rc
- if ~showlist('h',devname) then
- address command 'Mount' devname':' /* automatically mount it */
-
- dopus progress info bar abort
- handle=result
- dopus progress handle title 'Unpacking' dmsname'...'
-
- /* wow! some clever stuff here... */
- address command 'Run >T:UnDMS.'handle '<NIL: DMS <NIL: >PIPE:dmsout.'handle 'WRITE "'dmsfile'" TO' devname':' 'NOTEXT'
- call open('temp','T:UnDMS.'handle,'r')
- process=readln('temp')
- parse var process '[CLI ' process ']'
- close('temp')
- call delete('T:UnDMS.'handle)
-
- nomessage=1
- errorreport=''
- buffer=''
- call open('dmsout','PIPE:dmsout.'handle,'r') /* output from DMS comes through PIPE: */
-
- do until eof('dmsout')
- buffer=buffer||readch('dmsout',25) /* read portions of 25 characters */
- here=verify(buffer,'0a0d'x,'m') /* check for new lines */
- if here>0 then do
- line=left(buffer,here-1) /* one whole line */
- if nomessage&left(line,7)='No Disk' then do
- dopus progress handle info 'Insert disk in' devname
- nomessage=0
- end
- if pos('Write-Protected',line)>0 then do
- address command 'Break' process 'C'
- dopus progress handle off
- dopus front
- dopus request '"Disk in drive' devname 'is write protected." _OK'
- exit
- end
- parse var line ' ' line /* get rid of some ugly stuff */
- buffer=substr(buffer,here+1)
- if pos('ERROR',upper(line))>0 then do /* remember every line with the word 'error' in it */
- errorreport=errorreport||lf||line
- command flash
- end
- if pos('unPacking',line)>0 then do /* progress indication */
- track=right(line,2)
- dopus progress handle info 'Track' track
- dopus progress handle bar 80 track+1
- dopus progress handle abort
- if result then do
- address command 'Break' process 'C'
- dopus progress handle off
- exit
- end
- end
- end
- end
-
- call close('dmsout')
- dopus progress handle off
-
- if errorreport~=='' then do
- dopus front
- dopus request '"UnDMS Error Report for' dmsname||lf||errorreport'" _OK'
- end
-