(*-------------------------------------------------------------------------*)
(*                                                                         *)
(*  Amiga Oberon Library Module: Alerts               Date: 02-Nov-92      *)
(*                                                                         *)
(*   © 1992 by Fridtjof Siebert                                            *)
(*                                                                         *)
(*-------------------------------------------------------------------------*)

MODULE Alerts;

IMPORT Intuition, Exec, SYSTEM * ;

TYPE
  String = ARRAY 256 OF CHAR;

PROCEDURE * RFProc;                     (* $EntryExitCode- *)
BEGIN
  SYSTEM.INLINE(016C0U,  (* MOVE.B D0,(A3)+ *)
                04E75U); (* RTS             *)
END RFProc;


PROCEDURE AlertDummy * (s{8}: Exec.STRPTR; d{9}: SYSTEM.ADDRESS): BOOLEAN;
VAR
  str,string: String;
  i,j: INTEGER;
  y: INTEGER;
BEGIN
  Exec.OldRawDoFmt(s^,d,RFProc,SYSTEM.ADR(str));
  string[0] := 00X;
  string[1] := 32X;
  string[2] := 12X; y := ORD(12X);
  j := 3; i := 0;
  WHILE (j<255-8) & (str[i]#0X) DO
    string[j] := str[i];
    IF string[j]="\n" THEN
      INC(y,12);
      string[j] :=  00X; INC(j);
      string[j] := 0FFX; INC(j);
      string[j] :=  00X; INC(j);
      string[j] :=  32X; INC(j);
      string[j] := CHR(y);
    END;
    INC(i); INC(j);
  END;
  string[j] := 00X; INC(j);
  string[j] := 00X;
  RETURN Intuition.DisplayAlert(0,string,y+16)
END AlertDummy;


(*--------------------------------------------------------------------------*)


PROCEDURE Alert * {"Alerts.AlertDummy"} (s   {8}  : ARRAY OF CHAR;
                                         data{9}..: SYSTEM.ADDRESS): BOOLEAN;
(*
 * Display Alertmsg s with an arbritrary number of values to be inserted in
 * s, as it would be done by printf.
 *
 * Example:
 *   IF Alerts.Alert("My task (\"%s\") has trouble",
 *                   Exec.exec.thisTask.node.name)
 * THEN
 * END;
 *
 * As you may have noted, this declaration is a bit tricky and is not
 * recommended for usual use.
 *
 *)


END Alerts.


