home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 10 / Fresh_Fish_10_2352.bin / new / dev / obero / oberon-a / examples / libraries / intuition / easyrequest.mod < prev    next >
Text File  |  1995-07-02  |  2KB  |  96 lines

  1. (*************************************************************************
  2.  
  3.      $RCSfile: EasyRequest.mod $
  4.   Description:
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 1.4 $
  8.       $Author: fjc $
  9.         $Date: 1995/01/25 23:52:19 $
  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. *************************************************************************)
  16.  
  17. <* STANDARD- *>
  18.  
  19. MODULE EasyRequest;
  20.  
  21. IMPORT SYS := SYSTEM, e := Exec, d := Dos, i := Intuition, WbConsole;
  22.  
  23. CONST
  24.   VersionTag = "$VER: EasyRequest 1.4 (24.1.95)\r\n";
  25.  
  26. (*------------------------------------*)
  27. VAR
  28.  
  29.   myES : i.EasyStruct;
  30.  
  31.  
  32. (*------------------------------------
  33. ** Initialise the easy request structure.
  34. ** This uses many features of EasyRequest(), including:
  35. **    multiple lines of body text seperated by '\n'.
  36. **    variable substitution of a string (%s) in the body text.
  37. **    multiple button gadgets separated by '|'.
  38. **    variable substitution in a gadget (long decimal '%ld').
  39. *)
  40. PROCEDURE Init ();
  41.  
  42. BEGIN (* Init *)
  43.   myES.structSize := SIZE (i.EasyStruct);
  44.   myES.flags := {};
  45.   myES.title := SYS.ADR ("Request Window Name");
  46.   myES.textFormat :=
  47.     SYS.ADR ( "Text for the request\n"
  48.               "Second line of %s text\n"
  49.               "Third line of text for the request");
  50.   myES.gadgetFormat := SYS.ADR ("Yes|%ld|No");
  51. END Init;
  52.  
  53. (*------------------------------------*)
  54. PROCEDURE Main ();
  55.  
  56.   VAR
  57.     answer, number : LONGINT;
  58.  
  59. BEGIN (* Main *)
  60.   number := 3125794; (* For use in the middle button *)
  61.   (* note in the variable substitution:
  62.   **     the string goes in the first open variable (in body text).
  63.   **     the number goes in the second open (gadget text).
  64.   *)
  65.   answer :=
  66.     i.EasyRequest
  67.       ( NIL, SYS.ADR (myES), NIL,
  68.         SYS.ADR ("(Variable)"),
  69.         number );
  70.  
  71.   (* Process the answer.  Note that the buttons are numbered in
  72.   ** a strange order. This is because the rightmost button is
  73.   ** always a negative reply. The code can use this if it chooses,
  74.   ** with a construct like:
  75.   **
  76.   **     IF EasyRequest() > 0 THEN
  77.   **         PositiveResponse ()
  78.   **     END
  79.   *)
  80.   CASE answer OF
  81.     1 : d.PrintF ("selected 'Yes'\n", NIL)
  82.     |
  83.     2 : d.PrintF ("selected '%ld'\n", number)
  84.     |
  85.     0 : d.PrintF ("selected 'No'\n", NIL)
  86.     |
  87.   ELSE
  88.   END;
  89. END Main;
  90.  
  91. BEGIN (* EasyRequest *)
  92.   ASSERT (i.base.libNode.version >= 37);
  93.   Init ();
  94.   Main ();
  95. END EasyRequest.
  96.