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

  1. /* Insert.rexx */
  2.  
  3. options results; address MrMPEG; signal on syntax
  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. popasl ID FPATH; fpath = result
  14. temp_name = TmpFile('PIPE:MPEG_List.')
  15. address command 'RequestFile >'temp_name 'DRAWER "'fpath'" PATTERN "#?.(mp1|mp2|mp3)"
  16.   TITLE "Select MPEG files" MULTISELECT NOICONS'
  17. if RC = 0 then do
  18.   if open(1, temp_name, 'r') then do
  19.     do while ~eof(1)
  20.       if readch(1, 1) = '"' then do
  21.         temp_list = ''
  22.         do until temp_char = '"'
  23.           temp_char = readch(1, 1)
  24.           if eof(1) then break
  25.           if temp_char ~= '"' then temp_list = temp_list||temp_char
  26.         end
  27.         if exists(temp_list) then do
  28.           popasl ID PATH; pathname = result
  29.           temp_name = TmpFile('PIPE:MPEG_Temp.')
  30.           address command '"'pathname'MPEGA" -h "'first'" >'temp_name
  31.           if open(2, temp_name, 'r') then do
  32.             null = readln(2)
  33.             null = readln(2)
  34.             null = readln(2)
  35.             null = readln(2)
  36.             info = readln(2)
  37.             length = readln(2)
  38.             call close(2)
  39.             if left(info, 13) = '   File Type:' then do
  40.               parse var info dummy':' ''detail''
  41.               parse var length dummy':' ''temp_total_time''
  42.               if index(temp_list, ',') = 0 then do
  43.                 if entries = 0 then
  44.                   list ID SLIST INSERT POS MUIV_List_Insert_Bottom,
  45.                     STRING first","temp_total_time","strip(detail)
  46.                 else do
  47.                   list ID SLIST ATTRS MUIA_List_Entries; temp_max = result
  48.                   skip = 0
  49.                   do i = 0 to temp_max - 1
  50.                     list ID SLIST POS i
  51.                     parse var result temp_name','dummy
  52.                     if temp_list = temp_name then do
  53.                       skip = 1
  54.                       break
  55.                     end
  56.                   end
  57.                   if ~skip then
  58.                     list ID SLIST INSERT POS MUIV_List_Insert_Active,
  59.                       STRING first","temp_total_time","strip(detail)
  60.                 end
  61.               end /* of if index */
  62.               else request ID WARN GADGETS '"OK"' '"Cannot insert the filename with comma."'
  63.             end /* of if left */
  64.             else request ID WARN GADGETS '"OK"' '"Corrpted MPEG file."'
  65.           end /* of if open */
  66.           else request ID WARN GADGETS '"OK"' '"Could not open a pipe."'
  67.         end /* of if exists */
  68.         else do
  69.           temp_string = "Could not open the file '"first"'."
  70.           request ID WARN GADGETS '"OK"' temp_string
  71.         end
  72.       end /* of if readch */
  73.     end /* of do while */
  74.     call close(1)
  75.     list ID SLIST ATTRS MUIA_List_Entries; temp_max = result
  76.     setvar max temp_max
  77.     text ID MAX LABEL "\033b\033r"right(temp_max, 3)
  78.     temp_total_time = 0
  79.     do i = 0 to temp_max - 1
  80.       list ID SLIST POS i
  81.       parse var result dummy','temp_song_time','dummy2
  82.       temp_total_time = temp_total_time + left(temp_song_time, 2) * 60 + right(temp_song_time, 2)
  83.     end
  84.     temp_string = right(temp_total_time % 3600, 2, 0)||":"||,
  85.       right(temp_total_time // 3600 % 60, 2, 0)":"right(temp_total_time // 60, 2, 0)
  86.     setvar total_time temp_string
  87.     text ID TOTAL LABEL "\033b\033r"temp_string
  88.     if entries = 0 then list ID SLIST ATTRS MUIA_List_Active MUIV_List_Active_Top
  89.   end /* of if open */
  90.   else request ID WARN GADGETS '"OK"' '"Could not open a pipe."'
  91. end /* of if RC */
  92. window ID WIND2 ATTRS MUIA_Window_Sleep 0
  93. window ID WIND1 ATTRS MUIA_Window_Sleep 0
  94. return
  95.  
  96. syntax:
  97.   request ID WARN GADGETS '"OK"' '"\033b\033cError 'RC' in line 'SIGL':\033n\012\033c'errortext(RC)'"'
  98.   window ID WIND2 ATTRS MUIA_Window_Sleep 0
  99.   window ID WIND1 ATTRS MUIA_Window_Sleep 0
  100.   return
  101.