(****************************************************************************

$RCSfile: RequesterExample.mod $

$Revision: 1.1 $
    $Date: 1994/07/26 18:31:21 $

    GUIEnvironment V37.0 example: Requester

    M2Amiga Modula-2 Compiler V4.3

  Copyright © 1994, Carsten Ziegeler
                    Augustin-Wibbelt-Str.7, 33106 Paderborn, Germany

****************************************************************************)
MODULE RequesterExample;

(* This example shows all available requesters on the public screen.
   The requesters are not redirected ! The windowPtr field of the
   process structure is used ! (Usually this is NIL) *)

  FROM SYSTEM    IMPORT ADR, ADDRESS, TAG;
  FROM GUIEnvSupport IMPORT GERequestA;
IMPORT D:GUIEnvD, L:GUIEnvL;

CONST version = ADR('$VER: RequesterExample 1.1 (15.07.94)\n');

VAR choose : LONGINT;
    file, dir : ARRAY[0..255] OF CHAR;
    tagbuf : ARRAY[0..19] OF LONGCARD;
    args : ARRAY[0..4] OF ADDRESS; (* for the arguments *)

BEGIN

  (* Return value not needed, ok requester *)
  IGNORE GERequestA(ADR('This is the requester demo !\nEnjoy it !'),
                    D.gerOKKind, NIL);

  (* doitReqKind *)
  WHILE GERequestA(ADR('Do you want to see this requester again ?'),
                   D.gerDoItKind, NIL) = D.gerYes DO
  END;

  (* Yes/no/cancel  requester *)
  choose := GERequestA(ADR('Do you want to see some asl requesters ?'),
                       D.gerYNCKind, NIL);
  IF    choose = D.gerYes THEN

    (* And now the asl requesters supported by GUIEnvironment *)

    file := 'guienv.library';
    dir  := 'sys:libs';

    (* First a requester to choose the best library ! *)
    IF GERequestA(ADR('Choose the best library'), D.gerFileKind,
                  TAG(tagbuf, D.gerPattern, ADR('#?.library'),
                              D.gerFileBuffer, ADR(file),
                              D.gerDirBuffer, ADR(dir), NIL)) = D.gerYes THEN
      args[0] := ADR(dir);
      args[1] := ADR(file);
      IGNORE GERequestA(ADR('You choice was:\ndir : %s\nfile: %s'),
                        D.gerOKKind, TAG(tagbuf, D.gerArgs, ADR(args), NIL));
    ELSE
      IGNORE GERequestA(ADR('You cancelled it ! (Sniff..)'),
                        D.gerOKKind, NIL);
    END;

    (* And now a save dir requester with no pattern gadget *)
    dir := 'ram:t';
    IF GERequestA(ADR('Choose directory to save something...'),
                  D.gerDirKind, TAG(tagbuf, D.gerNameBuffer, ADR(dir),
                                            D.gerPattern, NIL,
                                            D.gerSave, TRUE, NIL)) = D.gerYes THEN

      args[0] := ADR(dir);
      IGNORE GERequestA(ADR('You selected directory:\n%s'),
                        D.gerOKKind, TAG(tagbuf, D.gerArgs, ADR(args), NIL));
    ELSE
      IGNORE GERequestA(ADR('You cancelled it ! (Snuff..)'),
                        D.gerOKKind, NIL);
    END;

  ELSIF choose = D.gerNo  THEN
    IGNORE GERequestA(ADR('Click OK to quit !'), D.gerOKKind, NIL);
  END;

END RequesterExample.
