home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / music / mrmidi / dropinsert.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1998-03-08  |  3.2 KB  |  85 lines

  1. /* DropInsert.rexx */
  2.  
  3. options results; address MrMIDI; signal on syntax; parse arg temp_list
  4.  
  5. MUIA_List_Active    = 0x8042391c;    MUIA_List_Entries    = 0x80421654
  6. MUIA_Window_Sleep    = 0x8042e7db;    MUIV_List_Active_Top    = -2
  7. MUIV_List_Insert_Active = -1;        MUIV_List_Insert_Bottom = -3
  8. MUIV_List_Insert_Sorted = -2
  9.  
  10. window ID WIND1 ATTRS MUIA_Window_Sleep 1
  11. window ID WIND2 ATTRS MUIA_Window_Sleep 1
  12. list ID SLIST ATTRS MUIA_List_Entries; entries = result
  13. if temp_list ~= "" then do
  14.   do forever
  15.     parse var temp_list first ',' temp_list
  16.     if first == '' then leave
  17.     if exists(first) then do
  18.       popasl ID PATH; pathname = result
  19.       temp_name = TmpFile('PIPE:MIDI_Temp.')
  20.       address command 'ReadMIDI "'first'" >'temp_name
  21.       if open('Output', temp_name, 'r') = 1 then do
  22.         null = readln('Output')
  23.         format = readln('Output')
  24.         total_tracks = readln('Output')
  25.         division = readln('Output')
  26.         temp_song_time = readln('Output')
  27.         call close('Output')
  28.         if left(null, 4) = 'MIDI' then do
  29.           parse var format dummy': 'format
  30.           parse var total_tracks dummy': 'total_tracks
  31.           parse var division dummy': 'division
  32.           parse var temp_song_time dummy': 'temp_song_time
  33.           if entries = 0 then
  34.             list ID SLIST INSERT POS MUIV_List_Insert_Bottom,
  35.               STRING first','temp_song_time','format','total_tracks','division
  36.           else do
  37.             list ID SLIST ATTRS MUIA_List_Entries; temp_max = result
  38.             skip = 0
  39.             do i = 0 to temp_max - 1
  40.               list ID SLIST POS i
  41.               parse var result temp_name','dummy
  42.               if first = temp_name then do
  43.                 skip = 1
  44.                 break
  45.               end
  46.             end
  47.             if ~skip then
  48.               list ID SLIST INSERT POS MUIV_List_Insert_Active,
  49.                 STRING first','temp_song_time','format','total_tracks','division
  50.           end
  51.         end /* of if null */
  52.         else request ID WARN GADGETS '"OK"' '"Corrupted MIDI file."'
  53.       end /* of if open */
  54.       else request ID WARN GADGETS '"OK"' '"Could not open a pipe."'
  55.     end /* of if exists */
  56.     else do
  57.       temp_string = "Could not open the file '"first"'."
  58.       request ID WARN GADGETS '"OK"' temp_string
  59.     end
  60.   end /* of do forever */
  61.   list ID SLIST ATTRS MUIA_List_Entries; temp_max = result
  62.   setvar max temp_max
  63.   text ID MAX LABEL "\033b\033r"right(temp_max, 3)
  64.   temp_total_time = 0
  65.   do i = 0 to temp_max - 1
  66.     list ID SLIST POS i
  67.     parse var result dummy','temp_song_time','dummy2
  68.     temp_total_time = temp_total_time + left(temp_song_time, 2) * 60 + right(temp_song_time, 2)
  69.   end
  70.   temp_string = right(temp_total_time % 3600, 2, 0)||":"||,
  71.     right(temp_total_time // 3600 % 60, 2, 0)":"right(temp_total_time // 60, 2, 0)
  72.   setvar total_time temp_string
  73.   text ID TOTAL LABEL "\033b\033r"temp_string
  74.   if entries = 0 then list ID SLIST ATTRS MUIA_List_Active MUIV_List_Active_Top
  75. end /* of if temp_list */
  76. window ID WIND2 ATTRS MUIA_Window_Sleep 0
  77. window ID WIND1 ATTRS MUIA_Window_Sleep 0
  78. return
  79.  
  80. syntax:
  81.   request ID WARN GADGETS '"OK"' '"\033b\033cError 'RC' in line 'SIGL':\033n\012\033c'errortext(RC)'"'
  82.   window ID WIND2 ATTRS MUIA_Window_Sleep 0
  83.   window ID WIND1 ATTRS MUIA_Window_Sleep 0
  84.   return
  85.