/* Delete.rexx */

options results; address MrMIDI; signal on syntax

MUIA_List_Active	= 0x8042391c;	MUIA_List_Entries	= 0x80421654
MUIA_Slider_Level	= 0x8042ae3a;	MUIA_Window_Sleep	= 0x8042e7db
MUIM_List_Remove	= 0x8042647e;	MUIV_List_Remove_Selected	= -3

window ID WIND1 ATTRS MUIA_Window_Sleep 1
window ID WIND2 ATTRS MUIA_Window_Sleep 1
need_to_stop = 1
getvar current_song; playing_name = result
list ID SLIST ATTRS MUIA_List_Entries; entries = result
if entries = 0 then do
  window ID WIND2 ATTRS MUIA_Window_Sleep 0
  window ID WIND1 ATTRS MUIA_Window_Sleep 0
  return
end
method ID SLIST MUIM_List_Remove MUIV_List_Remove_Selected
/* list ID SLIST REMOVE POS MUIV_List_Remove_Selected */
list ID SLIST ATTRS MUIA_List_Active
if result = 4294967295 then list ID SLIST ATTRS MUIA_List_Active 0

list ID SLIST ATTRS MUIA_List_Entries; temp_max = result
setvar max temp_max
text ID MAX LABEL "\033b\033r"right(temp_max, 3)
temp_total_time = 0
do i = 0 to temp_max - 1
  list ID SLIST POS i
  parse var result temp_name','temp_song_time','dummy
  temp_total_time = temp_total_time + left(temp_song_time, 2) * 60 + right(temp_song_time, 2)
  if temp_name = playing_name then do
    need_to_stop = 0
    list ID SLIST ATTRS MUIA_List_Active i
    setvar active i
    text ID ACTIV LABEL "\033b\033r"right(i + 1, 3)
  end
end
temp_string = right(temp_total_time % 3600, 2, 0)||":"||,
  right(temp_total_time // 3600 % 60, 2, 0)":"right(temp_total_time // 60, 2, 0)
setvar total_time temp_string
text ID TOTAL LABEL "\033b\033r"temp_string

if need_to_stop then do
  string ID FNAME CONTENT "No song is loaded."
  text ID LCD LABEL "MrMPEG is also available from Aminet."
  text ID ACTIV LABEL "\033b\033r  0"
  text ID CURNT LABEL "\033b\033r00:00"
  check ID PLAY
  if result = 1 then call Stop.rexx
/*  else slider ID PROG ATTRS MUIA_Slider_Level 0 */
end
window ID WIND2 ATTRS MUIA_Window_Sleep 0
window ID WIND1 ATTRS MUIA_Window_Sleep 0
return

syntax:
  request ID WARN GADGETS '"OK"' '"\033b\033cError 'RC' in line 'SIGL':\033n\012\033c'errortext(RC)'"'
  window ID WIND2 ATTRS MUIA_Window_Sleep 0
  window ID WIND1 ATTRS MUIA_Window_Sleep 0
  return
