/* Alert Client - DMS - March 98 - by Sylvain HUET */

typeof al=AlertWin;;

defcom SremoveAlarm = removeAlarm I;;

fun _end(b)=
 _DMSdelete this;;

fun removeAlarm (N) =
  _DMSsend this SremoveAlarm [N]
;;

fun _resize(x,s)=
 let x->[win x y w h] in _SIZEwindow al.winAlrtW w h x y;
 0;;

fun cbcloseWindow (win, param) = 
  _DMSdelete this
;;

fun startAlert(alrt)=
 let strcat "Alert." (_DMSgetName this) -> alrtname in
 set al=
  let _DMSgetZone this "Alert" nil @_resize @_end ->[win x y w h] in
  if win==nil then
   iniAlrtW _channel DMSwin nil nil 200 190
    alrtname nil 0 hd strextr alrt 
  else
   iniAlrtW _channel win x y w h
    alrtname nil 1 hd strextr alrt;
 0;;

fun destroyWindow () =
  _DMSdelete this
;;

fun __removeAlarm (N) =
  let nth_list al.alrtAlrtW N -> a in
    mutate a<-[_ 0];
  calcAlert al
;;

fun __alert(i)=_setAlert al i;;

fun IniDMI(param)=
 startAlert param;;