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

  1. /* ListLoad.rexx */
  2.  
  3. options results; address MrMIDI; signal on syntax; parse arg mode
  4.  
  5. ASLFR_DoPatterns    = 0x8008002E;    ASLFR_InitialDrawer    = 0x80080009
  6. ASLFR_InitialFile    = 0x80080008;    ASLFR_InitialPattern    = 0x8008000A
  7. MUIA_List_Active    = 0x8042391c;    MUIA_List_Entries    = 0x80421654
  8. MUIA_Window_Sleep    = 0x8042e7db;    MUIV_List_Active_Top    = -2
  9. MUIV_List_Insert_Active = -1;        MUIV_List_Insert_Bottom = -3
  10. MUIV_List_Insert_Sorted = -2
  11.  
  12. window ID WIND1 ATTRS MUIA_Window_Sleep 1
  13. window ID WIND2 ATTRS MUIA_Window_Sleep 1
  14. RC = 0
  15. if mode = 1 then do
  16.   aslrequest ATTRS ASLFR_InitialDrawer '"ENVARC:"' ASLFR_InitialFile,
  17.     '"MrMIDI.list"' ASLFR_InitialPattern '"#?.list"' ASLFR_DoPatterns 1,
  18.     TITLE '"Load a list"'
  19.   temp_list = result
  20.   end
  21. else if mode = 2 then do
  22.   aslrequest ATTRS ASLFR_InitialDrawer '"ENVARC:"' ASLFR_InitialFile,
  23.     '"MrMIDI.list"' ASLFR_InitialPattern '"#?.list"' ASLFR_DoPatterns 1,
  24.     TITLE '"Include a list"'
  25.   temp_list = result
  26.   end
  27. else temp_list = "ENV:MrMIDI.list"
  28. if RC = 0 then do
  29.   if open(1, temp_list, 'r') then do
  30.     if mode = 1 then call Clear.rexx
  31.     list ID SLIST ATTRS MUIA_List_Entries; entries = result
  32.     do forever
  33.       temp = readln(1)
  34.       if eof(1) then leave
  35.       if entries = 0 then
  36.         list ID SLIST INSERT POS MUIV_List_Insert_Bottom STRING temp
  37.       else do
  38.         list ID SLIST ATTRS MUIA_List_Entries; temp_max = result
  39.         skip = 0
  40.         do i = 0 to temp_max - 1
  41.           list ID SLIST POS i
  42.           if temp = result 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 STRING temp
  49.       end /* of if entries */
  50.     end /* of do forever */
  51.     call close(1)
  52.     list ID SLIST ATTRS MUIA_List_Entries; temp_max = result
  53.     setvar max temp_max
  54.     text ID MAX LABEL "\033b\033r"right(temp_max, 3)
  55.     temp_total_time = 0
  56.     do i = 0 to temp_max - 1
  57.       list ID SLIST POS i
  58.       parse var result dummy','temp_song_time','dummy2
  59.       temp_total_time = temp_total_time + left(temp_song_time, 2) * 60 + right(temp_song_time, 2)
  60.     end
  61.     temp_string = right(temp_total_time % 3600, 2, 0)||":"||,
  62.       right(temp_total_time // 3600 % 60, 2, 0)":"right(temp_total_time // 60, 2, 0)
  63.     setvar total_time temp_string
  64.     text ID TOTAL LABEL "\033b\033r"temp_string
  65.     if entries = 0 then list ID SLIST ATTRS MUIA_List_Active MUIV_List_Active_Top
  66.   end /* of if open */
  67.   else do
  68.     temp_string = "Could not open the file '"temp_list"'."
  69.     request ID WARN GADGETS '"OK"' temp_string
  70.   end
  71. end /* of if RC */
  72. window ID WIND2 ATTRS MUIA_Window_Sleep 0
  73. window ID WIND1 ATTRS MUIA_Window_Sleep 0
  74. return
  75.  
  76. syntax:
  77.   request ID WARN GADGETS '"OK"' '"\033b\033cError 'RC' in line 'SIGL':\033n\012\033c'errortext(RC)'"'
  78.   window ID WIND2 ATTRS MUIA_Window_Sleep 0
  79.   window ID WIND1 ATTRS MUIA_Window_Sleep 0
  80.   return
  81.