home *** CD-ROM | disk | FTP | other *** search
- /*
-
- This is an example ARexx script for use with MidiPlay. Use the following
- parameter: FILETYPEREXX=ThisScript.rexx When MidiPlay cannot load a file,
- because it is not a MIDI file, it calls ThisScript. Argument consists of
- drive, path, file and extension of the filename.
-
- This particular example tries to decrunch a powerpacked file or a file with
- extension lha to a directory T:rxmidi. If unarchiving (lha) is succesful,
- the first .MID file is played (powerpacked files will be first copied to
- this directory, then decrunched and then played) Files will be sent back to
- MidiPlay by sending command 'FILE filename'
-
- */
-
- options results
-
- lhacommand = 'sys:archivers/lha >nil: -x0 -q e '
- ppackcommand = 'sys:archivers/xpack >nil: '
- destdir = 'T:rxmidi/'
-
- parse arg Drive ',' Path ',' File ',' Extension .
-
- address command
-
- if ~show('L',"rexxsupport.library") then do
- if ~addlib('rexxsupport.library',0,-30,0) then
- exit 10
- end
-
- if ~exists('t:rxmidi') then
- 'makedir t:rxmidi'
-
- if Path == "" then Path2 = Path
- else Path2 = Path || '/'
-
- Whole = Drive || Path2 || File
- if Extension ~= '' then Whole = Whole || '.' || Extension
-
-
- /* previous unarchived files should be deleted */
-
- "delete >nil: t:rxmidi/#?"
-
- /* Is it powerpacked file ? */
-
- e = open(pfile,Whole,'Read')
- lstr = readch(pfile,4)
-
- if compare(lstr,'PP20')=0 then do /* yes, powerpacked */
- filenam = File
- if Extension ~= '' then filenam = File || '.' || Extension
-
- /* copy the original file to destdir */
-
- copy '"'Whole'"' TO destdir || filenam
- ppackcommand destdir || filenam
-
- /* copy (not compressed) icon file too */
-
- iconfile = '"'Whole || '.info'|| '"'
- copy iconfile destdir
- end
- else do /* not powerpacked, maybe lha archive ? */
- if Extension='lha' | Extension='LHA' then
- lhacommand '"'Whole'"' destdir
- else do
- say 'Not a MIDI file' Whole
- RETURN
- end
-
- dir1=showdir(destdir,'f','@')
- dir1=insert(dir1,'@')
- dir2=upper(dir1)
-
- position=index(dir2,'.MID')
- position3=lastpos('@',dir2,position)
- position2=index(dir2,'.MID',position)
- filenam=substr(dir2,position3+1,(position2-position3)+3)
- end
-
- address "MidiPlay_rexx"
- 'FILE ' destdir || filenam
-