home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / dev / obero / oberon-a / examples / libraries / intuition / easyrequest.mod < prev    next >
Encoding:
Text File  |  1994-08-08  |  3.0 KB  |  115 lines

  1. (*************************************************************************
  2.  
  3.      $RCSfile: EasyRequest.mod $
  4.   Description:
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 1.2 $
  8.       $Author: fjc $
  9.         $Date: 1994/08/08 16:55:25 $
  10.  
  11.   Copyright © 1994, Frank Copeland.
  12.   This example program is part of Oberon-A.
  13.   See Oberon-A.doc for conditions of use and distribution.
  14.  
  15.   Log entries are at the end of the file.
  16.  
  17. *************************************************************************)
  18.  
  19. MODULE EasyRequest;
  20.  
  21. (*
  22. ** $C= CaseChk       $I= IndexChk  $L= LongAdr   $N= NilChk
  23. ** $P- PortableCode  $R= RangeChk  $S= StackChk  $T= TypeChk
  24. ** $V= OvflChk       $Z= ZeroVars
  25. *)
  26.  
  27. IMPORT SYS := SYSTEM, e := Exec, d := Dos, i := Intuition;
  28.  
  29. CONST
  30.   VersionTag = "$VER: EasyRequest 1.1 (5.7.94)";
  31.  
  32. (*------------------------------------*)
  33. VAR
  34.  
  35.   myES : i.EasyStruct;
  36.  
  37.  
  38. (*------------------------------------
  39. ** Initialise the easy request structure.
  40. ** This uses many features of EasyRequest(), including:
  41. **    multiple lines of body text seperated by '\n'.
  42. **    variable substitution of a string (%s) in the body text.
  43. **    multiple button gadgets separated by '|'.
  44. **    variable substitution in a gadget (long decimal '%ld').
  45. *)
  46. PROCEDURE Init ();
  47.  
  48. BEGIN (* Init *)
  49.   myES.structSize := SIZE (i.EasyStruct);
  50.   myES.flags := {};
  51.   myES.title := SYS.ADR ("Request Window Name");
  52.   myES.textFormat :=
  53.     SYS.ADR ( "Text for the request\n"
  54.               "Second line of %s text\n"
  55.               "Third line of text for the request");
  56.   myES.gadgetFormat := SYS.ADR ("Yes|%ld|No");
  57. END Init;
  58.  
  59. (*------------------------------------*)
  60. PROCEDURE Main ();
  61.  
  62.   VAR
  63.     answer, number : LONGINT;
  64.  
  65. BEGIN (* Main *)
  66.   number := 3125794; (* For use in the middle button *)
  67.   IF i.base.version >= 37 THEN
  68.     (* note in the variable substitution:
  69.     **     the string goes in the first open variable (in body text).
  70.     **     the number goes in the second open (gadget text).
  71.     *)
  72.     answer :=
  73.       i.base.EasyRequest
  74.         ( NIL, SYS.ADR (myES), NIL,
  75.           SYS.ADR ("(Variable)"),
  76.           number );
  77.  
  78.     (* Process the answer.  Note that the buttons are numbered in
  79.     ** a strange order. This is because the rightmost button is
  80.     ** always a negative reply. The code can use this if it chooses,
  81.     ** with a construct like:
  82.     **
  83.     **     IF EasyRequest() > 0 THEN
  84.     **         PositiveResponse ()
  85.     **     END
  86.     *)
  87.     CASE answer OF
  88.       1 : d.base.PrintF ("selected 'Yes'\n", NIL)
  89.       |
  90.       2 : d.base.PrintF ("selected '%ld'\n", number)
  91.       |
  92.       0 : d.base.PrintF ("selected 'No'\n", NIL)
  93.       |
  94.     ELSE
  95.     END;
  96.   END;
  97. END Main;
  98.  
  99. BEGIN (* EasyRequest *)
  100.   Init ();
  101.   Main ();
  102. END EasyRequest.
  103.  
  104. (*************************************************************************
  105.  
  106.   $Log: EasyRequest.mod $
  107.   Revision 1.2  1994/08/08  16:55:25  fjc
  108.   Release 1.4
  109.  
  110.   Revision 1.1  1994/06/17  18:19:27  fjc
  111.   Initial revision
  112.  
  113. *************************************************************************)
  114.  
  115.