/* Prev.rexx */

options results; address MrMIDI

MUIA_Selected		= 0x8042654b;	MUIA_List_Active	= 0x8042391c
MUIA_List_Entries	= 0x80421654;	MUIV_List_Active_Bottom	= -3
MUIV_List_Active_Up	= -4

list ID SLIST ATTRS MUIA_List_Entries; max = result
list ID SLIST ATTRS MUIA_List_Active; current = result
if max > 1 then do
  check ID RAND; rnd = result
  if rnd = 1 then do
    flag = 0
    do while flag = 0
    temp = random(0, max - 1, time('S'))
      if temp ~= current then do
        list ID SLIST ATTRS MUIA_List_Active temp
        flag = 1
      end
    end /* of while flag */
  end /* of if rnd */
  else if current ~= 0 then list ID SLIST ATTRS MUIA_List_Active MUIV_List_Active_Up
  else list ID SLIST ATTRS MUIA_List_Active MUIV_List_Active_Bottom
  list ID SLIST ATTRS MUIA_List_Active; temp_active = result
  setvar active temp_active
  check ID PLAY
  if result = 1 then do
    call Stop()
    delay(20)
    check ID PLAY ATTRS MUIA_Selected 1
  end
  text ID ACTIV LABEL "\033b\033r"right(temp_active + 1, 3)
  call GetInfo()
end
return
