home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / TESTS / SRC / edittest.mod next >
Text File  |  1997-11-10  |  6KB  |  166 lines

  1. MODULE EditTest;
  2.  
  3.         (********************************************************)
  4.         (*                                                      *)
  5.         (*              Test of module ScreenEditor             *)
  6.         (*                                                      *)
  7.         (*  Programmer:         P. Moylan                       *)
  8.         (*  Last edited:        10 November 1997                *)
  9.         (*  Status:             Working but incomplete          *)
  10.         (*                                                      *)
  11.         (*      This program tests only a subset of the         *)
  12.         (*      options supported by ScreenEditor.  More        *)
  13.         (*      work needed on further tests.                   *)
  14.         (*                                                      *)
  15.         (********************************************************)
  16.  
  17. FROM Windows IMPORT
  18.     (* type *)  Window, Colour, FrameType, DividerType,
  19.     (* proc *)  OpenWindow, CloseWindow, SetCursor, WriteString, PressAnyKey;
  20.  
  21. FROM NumericIO IMPORT
  22.     (* proc *)  WriteRJCard;
  23.  
  24. FROM RealIO IMPORT
  25.     (* proc *)  WriteReal;
  26.  
  27. FROM Menus IMPORT
  28.     (* type *)  Menu, ItemText, MenuOption, MO,
  29.     (* proc *)  CreateMenu, SetOptions;
  30.  
  31. FROM ScreenEditor IMPORT
  32.     (* type *)  Structure,
  33.     (* proc *)  CardinalField, RealField, MenuField, StringField, Combine,
  34.                 MakeArray, ScreenEdit;
  35.  
  36. (************************************************************************)
  37.  
  38. CONST maxsubscript = 10;
  39.  
  40. TYPE
  41.     subscript = [1..maxsubscript];
  42.     TestRecord = RECORD
  43.                     part1: REAL;
  44.                  END (*RECORD*);
  45.  
  46. VAR
  47.     TestData: ARRAY subscript OF TestRecord;
  48.  
  49. (************************************************************************)
  50.  
  51. PROCEDURE CreateAMenu(): Menu;
  52.  
  53.     (* Creates a menu. *)
  54.  
  55.     VAR menu: Menu;
  56.         menutext: ARRAY [0..25] OF ItemText;
  57.  
  58.     BEGIN
  59.         menutext[0] := "MENU 1";
  60.         menutext[1] := "The";
  61.         menutext[2] := "quick";
  62.         menutext[3] := "brown";
  63.         menutext[4] := "fox";
  64.         menutext[5] := "jumps";
  65.         menutext[6] := "over";
  66.         menutext[7] := "the";
  67.         menutext[8] := "lazy";
  68.         menutext[9] := "dog";
  69.         menutext[10] := "Now";
  70.         menutext[11] := "is";
  71.         menutext[12] := "the";
  72.         menutext[13] := "time";
  73.         menutext[14] := "for";
  74.         menutext[15] := "all";
  75.         menutext[16] := "good";
  76.         menutext[17] := "men";
  77.         menutext[18] := "to";
  78.         menutext[19] := "come";
  79.         menutext[20] := "to";
  80.         menutext[21] := "the";
  81.         menutext[22] := "aid";
  82.         menutext[23] := "of";
  83.         menutext[24] := "the";
  84.         menutext[25] := "party";
  85.         CreateMenu (menu, 3, menutext, 25);
  86.         SetOptions (menu, MO{MNoBorder});
  87.         RETURN menu;
  88.     END CreateAMenu;
  89.  
  90. (****************************************************************)
  91.  
  92. PROCEDURE RunTheTest;
  93.  
  94.     VAR w: Window;  R, S, count: Structure;  abort: BOOLEAN;
  95.         x: CARDINAL;  y: REAL;  z: REAL;  graphics: BOOLEAN;
  96.         menuvar: CARDINAL;  row: CARDINAL;
  97.         stringvar: ARRAY [0..31] OF CHAR;
  98.  
  99.     BEGIN
  100.         OpenWindow (w, black, green, 1, 18, 10, 69, simpleframe, nodivider);
  101.  
  102.         (* Start with a structure containing a few simple variables. *)
  103.  
  104.         x := 1234;  y := 3.14159;  graphics := FALSE;
  105.         SetCursor (w, 3, 2);  WriteString (w, "x      [");
  106.         SetCursor (w, 3, 18);  WriteString (w, "]");
  107.         SetCursor (w, 5, 2);  WriteString (w, "y      [");
  108.         SetCursor (w, 5, 20);  WriteString (w, "]");
  109.         SetCursor (w, 5, 30);  WriteString (w, "z      [");
  110.         SetCursor (w, 5, 50);  WriteString (w, "]");
  111.         (*
  112.         SetCursor (w, 7, 2);  WriteString (w, "graphics");
  113.         SetCursor (w, 7, 10);  WriteString (w, "OFF");
  114.         *)
  115.  
  116.         R := CardinalField (x, 3, 10, 8);
  117.         Combine (R, StringField (stringvar, 4, 10, 8));
  118.         Combine (R, RealField (z, 5, 40, 10));
  119.         Combine (R, RealField (y, 5, 10, 10));
  120.  
  121.    (*   AddBooleanField (S, graphics, 7, 10, "NO", "YES");  *)
  122.  
  123.    (*   ScreenEdit (w, R, abort);   *)
  124.  
  125.         (* Include elements of an array. *)
  126.  
  127.         Combine (R, RealField (TestData[1].part1, 1, 3, 10));
  128.         Combine (R, RealField (TestData[2].part1, 2, 3, 10));
  129.  
  130.         (* Add a menu field. *)
  131.  
  132.         menuvar := 2;
  133.         Combine (R, MenuField (menuvar, 7, 5, 6, 30, CreateAMenu()));
  134.  
  135.         (* Go to it: do some editing. *)
  136.  
  137.         ScreenEdit (w, R, abort);
  138.  
  139.         SetCursor (w, 14, 1);  WriteString (w, "x, y, z = ");
  140.         WriteRJCard (w, x, 8);  WriteString (w, ", ");
  141.         WriteReal (w, y, 10);  WriteString (w, ", ");
  142.         WriteReal (w, z, 10);
  143.         SetCursor (w, 15, 1);  WriteString (w, "graphics is o");
  144.         IF graphics THEN WriteString (w, "n");
  145.         ELSE WriteString (w, "ff");
  146.         END (*IF*);
  147.  
  148.         (* Test 3: repeating structure. *)
  149. (*
  150.         S := MakeArray (R, maxsubscript, SIZE(TestRecord), 1, 0);
  151.         ScreenEdit (w, S);
  152. *)
  153.         PressAnyKey (w);
  154.         PressAnyKey (w);
  155.         CloseWindow (w);
  156.     END RunTheTest;
  157.  
  158. (************************************************************************)
  159. (*                              MAIN PROGRAM                            *)
  160. (************************************************************************)
  161.  
  162. BEGIN
  163.     RunTheTest;
  164. END EditTest.
  165. 
  166.