home *** CD-ROM | disk | FTP | other *** search
/ Merciful 3 / Merciful_Release_3.bin / software / m / midiplayv2.58.lha / MidiPlay / ARexx / Example3.rexx < prev    next >
OS/2 REXX Batch file  |  1995-02-28  |  2KB  |  84 lines

  1. /* 
  2.  
  3. This  is  an example ARexx script for use with MidiPlay.  Use the following
  4. parameter:   FILETYPEREXX=ThisScript.rexx When MidiPlay cannot load a file,
  5. because  it  is not a MIDI file, it calls ThisScript.  Argument consists of
  6. drive, path, file and extension of the filename.
  7.  
  8. This particular example tries to decrunch a powerpacked file or a file with
  9. extension  lha to a directory T:rxmidi.  If unarchiving (lha) is succesful,
  10. the  first  .MID  file is played (powerpacked files will be first copied to
  11. this directory, then decrunched and then played) Files will be sent back to
  12. MidiPlay by sending command 'FILE filename'
  13.  
  14. */
  15.  
  16. options results
  17.  
  18. lhacommand = 'sys:archivers/lha >nil: -x0 -q e '
  19. ppackcommand = 'sys:archivers/xpack >nil: '
  20. destdir = 'T:rxmidi/'
  21.  
  22. parse arg Drive ',' Path ',' File ',' Extension .
  23.  
  24. address command
  25.  
  26. if ~show('L',"rexxsupport.library") then do
  27.   if ~addlib('rexxsupport.library',0,-30,0) then
  28.     exit 10
  29. end
  30.  
  31. if ~exists('t:rxmidi') then
  32.   'makedir t:rxmidi'
  33.  
  34. if Path == "" then Path2 = Path
  35. else Path2 = Path || '/'
  36.  
  37. Whole = Drive || Path2 || File
  38. if Extension ~= '' then Whole = Whole || '.' || Extension
  39.  
  40.  
  41. /* previous unarchived files should be deleted */
  42.  
  43. "delete >nil: t:rxmidi/#?"
  44.  
  45. /* Is it powerpacked file ? */
  46.  
  47. e = open(pfile,Whole,'Read')
  48. lstr = readch(pfile,4)
  49.  
  50. if compare(lstr,'PP20')=0 then do /* yes, powerpacked */
  51.     filenam = File
  52.     if Extension ~= '' then filenam = File || '.' || Extension
  53.  
  54.     /* copy the original file to destdir */
  55.  
  56.     copy '"'Whole'"' TO destdir || filenam
  57.     ppackcommand destdir || filenam
  58.  
  59.     /* copy (not compressed) icon file too */
  60.  
  61.     iconfile = '"'Whole || '.info'|| '"'
  62.     copy iconfile destdir
  63. end
  64. else do /* not powerpacked, maybe lha archive ? */
  65.     if Extension='lha' | Extension='LHA' then
  66.         lhacommand '"'Whole'"' destdir
  67.     else     do
  68.            say 'Not a MIDI file' Whole
  69.            RETURN
  70.         end
  71.  
  72.     dir1=showdir(destdir,'f','@')
  73.     dir1=insert(dir1,'@')
  74.     dir2=upper(dir1)
  75.  
  76.     position=index(dir2,'.MID')
  77.     position3=lastpos('@',dir2,position)
  78.     position2=index(dir2,'.MID',position)
  79.     filenam=substr(dir2,position3+1,(position2-position3)+3)
  80. end
  81.  
  82. address "MidiPlay_rexx"
  83. 'FILE ' destdir || filenam
  84.