home *** CD-ROM | disk | FTP | other *** search
/ The Best of Mecomp Multimedia 2 / MECOMP-CD-II.iso / amiga / sound / mrmpeg / eject.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1998-03-07  |  5.1 KB  |  134 lines

  1. /* Eject.rexx */
  2.  
  3. options results; address MrMPEG; signal on syntax
  4.  
  5. ASLFR_InitialDrawer    = 0x80080009;    ASLFR_InitialFile    = 0x80080008
  6. MUIA_List_Active    = 0x8042391c;    MUIA_List_Entries    = 0x80421654
  7. MUIA_Window_Sleep    = 0x8042e7db;    MUIV_List_Active_Top    = -2
  8. MUIV_List_Insert_Active = -1;        MUIV_List_Insert_Bottom = -3
  9. MUIV_List_Insert_Sorted = -2
  10.  
  11. window ID WIND1 ATTRS MUIA_Window_Sleep 1
  12. window ID WIND2 ATTRS MUIA_Window_Sleep 1
  13. RC = 0
  14. popasl ID FPATH; fpath = result
  15. temp_name = TmpFile('PIPE:MPEG_List.')
  16. address command 'RequestFile >'temp_name' DRAWER "'fpath'" PATTERN "#?.(mp1|mp2|mp3|list)"
  17.   TITLE "Select MPEG files/song lists" MULTISELECT NOICONS'
  18. if RC = 0 & open(1, temp_name, 'r') then do
  19.   list ID SLIST ATTRS MUIA_List_Entries; entries = result
  20.   if entries ~= 0 then do
  21.     call Clear.rexx
  22.     entries = 0
  23.   end
  24.   do while ~eof(1)
  25.     if readch(1, 1) = '"' then do
  26.       temp_list = ''
  27.       do until temp_char = '"'
  28.         temp_char = readch(1, 1)
  29.         if eof(1) then break
  30.         if temp_char ~= '"' then temp_list = temp_list||temp_char
  31.       end
  32.       if exists(temp_list) then do
  33.         if translate(right(temp_list, 5)) = '.LIST' then do
  34.           if open(2, temp_list, 'r') then do
  35.             do forever
  36.               temp = readln(2)
  37.               if eof(2) then leave
  38.               if entries = 0 then
  39.                 list ID SLIST INSERT POS MUIV_List_Insert_Bottom STRING temp
  40.               else do
  41.                 list ID SLIST ATTRS MUIA_List_Entries; temp_max = result
  42.                 skip = 0
  43.                 do i = 0 to temp_max - 1
  44.                   list ID SLIST POS i
  45.                   if temp = result then do
  46.                     skip = 1
  47.                     break
  48.                   end
  49.                 end
  50.                 if ~skip then
  51.                   list ID SLIST INSERT POS MUIV_List_Insert_Active STRING temp
  52.               end /* of if entries */
  53.             end /* of do forever */
  54.             call close(2)
  55.           end /* of if open */
  56.           else do
  57.             temp_string = "Could not open the file '"temp_list"'."
  58.             request ID WARN GADGETS '"OK"' temp_string
  59.           end
  60.         end /* of if right */
  61.         else do
  62.           popasl ID PATH; pathname = result
  63.           temp_name = TmpFile('PIPE:MPEG_Temp.')
  64.           address command '"'pathname'MPEGA" -h "'temp_list'" >'temp_name
  65.           if open(2, temp_name, 'r') then do
  66.             null = readln(2)
  67.             null = readln(2)
  68.             null = readln(2)
  69.             null = readln(2)
  70.             info = readln(2)
  71.             length = readln(2)
  72.             call close(2)
  73.             if left(info, 13) = '   File Type:' then do
  74.               parse var info dummy':' ''detail''
  75.               parse var length dummy':' ''temp_total_time''
  76.               if index(temp_list, ',') = 0 then do
  77.                 if entries = 0 then
  78.                   list ID SLIST INSERT POS MUIV_List_Insert_Bottom,
  79.                     STRING temp_list","temp_total_time","strip(detail)
  80.                 else do
  81.                   list ID SLIST ATTRS MUIA_List_Entries; temp_max = result
  82.                   skip = 0
  83.                   do i = 0 to temp_max - 1
  84.                     list ID SLIST POS i
  85.                     parse var result temp_name','dummy
  86.                     if temp_list = temp_name then do
  87.                       skip = 1
  88.                       break
  89.                     end
  90.                   end
  91.                   if ~skip then
  92.                     list ID SLIST INSERT POS MUIV_List_Insert_Active,
  93.                       STRING temp_list","temp_total_time","strip(detail)
  94.                 end
  95.               end /* of if index */
  96.               else request ID WARN GADGETS '"OK"' '"Cannot insert the filename with comma."'
  97.             end /* of if null */
  98.             else request ID WARN GADGETS '"OK"' '"Corrupted MPEG file."'
  99.           end /* of if open */
  100.           else request ID WARN GADGETS '"OK"' '"Could not open a pipe."'
  101.         end
  102.       end /* of if exists */
  103.       else do
  104.         temp_string = "Could not open the file '"temp_list"'."
  105.         request ID WARN GADGETS '"OK"' temp_string
  106.       end
  107.     end /* of if readch */
  108.   end /* of do while */
  109.   call close(1)
  110.   list ID SLIST ATTRS MUIA_List_Entries; temp_max = result
  111.   setvar max temp_max
  112.   text ID MAX LABEL "\033b\033r"right(temp_max, 3)
  113.   temp_total_time = 0
  114.   do i = 0 to temp_max - 1
  115.     list ID SLIST POS i
  116.     parse var result dummy','temp_song_time','dummy2
  117.     temp_total_time = temp_total_time + left(temp_song_time, 2) * 60 + right(temp_song_time, 2)
  118.   end
  119.   temp_string = right(temp_total_time % 3600, 2, 0)||":"||,
  120.     right(temp_total_time // 3600 % 60, 2, 0)":"right(temp_total_time // 60, 2, 0)
  121.   setvar total_time temp_string
  122.   text ID TOTAL LABEL "\033b\033r"temp_string
  123.   list ID SLIST ATTRS MUIA_List_Active MUIV_List_Active_Top
  124. end /* of if open */
  125. window ID WIND2 ATTRS MUIA_Window_Sleep 0
  126. window ID WIND1 ATTRS MUIA_Window_Sleep 0
  127. return
  128.  
  129. syntax:
  130.   request ID WARN GADGETS '"OK"' '"\033b\033cError 'RC' in line 'SIGL':\033n\012\033c'errortext(RC)'"'
  131.   window ID WIND2 ATTRS MUIA_Window_Sleep 0
  132.   window ID WIND1 ATTRS MUIA_Window_Sleep 0
  133.   return
  134.