home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MGTP4.ZIP / WIDGIT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-11-11  |  5.7 KB  |  169 lines

  1. {$R-}    {Range checking off}
  2. {$B-}    {Boolean short circuiting off}
  3. {$S+}    {Stack checking on}
  4. {$I+}    {I/O checking on}
  5. {$N-}    {No numeric coprocessor}
  6. {$M 65500,16384,655360} {Turbo 3 default stack and heap}
  7.  
  8. Program WidgitProg(Input,Output);
  9. {  8/30/87 :   Data entry and screen handling are the strong suits of MiniGen.
  10.              This program demonstrates the use of MiniGen generated procedures
  11.              to get a program up and running quickly. After setting up the
  12.              background color and clearing the screen, call the procedure you
  13.              created with the MiniGen screen painter to display the main
  14.              screen. Calls to EnterData() will gather your data which can then
  15.              be written to a file or processed however you choose.
  16.                While the structure of this program is quite simple, it does a
  17.              lot for you. A better way to gather your data would be to use a
  18.              case structure when calling EnterData(). The case selector should
  19.              be a byte variable, while the case labels represent input fields
  20.              numbered top to bottom, left to right on the screen. Hitting
  21.              return or the tab key ( --> ), should take the user to the next
  22.              field. Conversely, the back tab key ( <-- ), should take the user
  23.              to the previous field. By embedding the case statement in a
  24.              Repeat/Until loop and initializing the case selector to one,
  25.              you can use the return code of EnderData to increment or
  26.              decrement the case selector at the bottom of the loop. That will
  27.              take you up and down the screen.
  28.                In future versions of MiniGen, this data entry procedure will
  29.              be automated, making the promise of full data entry application
  30.              generation a reality. Until then, this program architecture should
  31.              be easy to create, allowing you to turn out data entry programs
  32.              in a couple of hours (once you get the hang of it), as I did with
  33.              this one.
  34.  
  35.       Minigen Products
  36.       Eric H. Snyder
  37.       1417 Evergreen
  38.       Homewood, IL  60430
  39. }
  40.  
  41. Uses
  42.   Crt,
  43.   MGProg;
  44.  
  45. Const
  46.   ScreenCount = 1;       { Enter the number of screens you wish to define }
  47.  
  48. {$I \TP\MG2\WIDGIT.INC}          { Screen procedure developed with MiniGen }
  49.  
  50.                          { Enter any ScrnGen window procedres here }
  51.  
  52. Var
  53.   ReturnCode  : Integer;
  54.   Continue    : Char;
  55.   Name        : String[25];
  56.   Addr1,Addr2 : String[30];
  57.   City        : String[12];
  58.   State       : String[2];
  59.   Zip         : String[5];
  60.   SSN1        : String[3];
  61.   SSN2        : String[2];
  62.   SSN3        : String[4];
  63.   Cash,Check,
  64.   Charge      : Char;
  65.   Each,Box,
  66.   _Case       : Char;
  67.   Quantity    : Integer;
  68.   Discount    : Integer;
  69.   Price       : Real;
  70.   Extension   : Real;
  71.  
  72. Type
  73.   CharSet = Set of Char;
  74.  
  75. Function GetChar(Var CharIn:Char;XLoc,YLoc:Integer;
  76.                      GoodChars,CharExits:Charset) : Integer;
  77. Var
  78.   Ch : Char;
  79. Begin
  80. GotoXY(Xloc,YLoc);
  81. Repeat
  82.   Ch := ReadKey;
  83. Until (Ch in (GoodChars + CharExits));
  84. If Ch in GoodChars then
  85.   Begin
  86.   CharIn := Ch;
  87.   Write(Ch);
  88.   End;
  89. GetChar := 0;
  90. If Ch in CharExits then
  91.   GetChar := Ord(Ch);
  92. End; {GetChar}
  93.  
  94. Procedure MainLoop;      { Main program logic }
  95. Begin
  96. TextBackground(Blue);
  97. Continue := 'Y';
  98. Repeat
  99.   ClrScr;
  100.   WidgitOEScreen;
  101.   MG_TimeOut := 30;
  102.   Name       := '';
  103.   Addr1      := '';
  104.   Addr2      := '';
  105.   City       := '';
  106.   State      := '';
  107.   Zip        := '';
  108.   SSN1       := '';
  109.   SSN2       := '';
  110.   SSN3       := '';
  111.   Cash       := ' ';
  112.   Check      := ' ';
  113.   Charge     := ' ';
  114.   Each       := ' ';
  115.   Box        := ' ';
  116.   _Case      := ' ';
  117.   Quantity   := 1;
  118.   Discount   := 0;
  119.   Price      := 0.0;
  120.   ReturnCode := EnterData(Name, 'S',22, 7,25,0,78,$87,[27]);
  121.   ReturnCode := EnterData(Addr1,'S',22, 8,30,0,78,$87,[27]);
  122.   ReturnCode := EnterData(Addr2,'S',22, 9,30,0,78,$87,[27]);
  123.   ReturnCode := EnterData(City, 'S',22,10,12,0,78,$87,[27]);
  124.   ReturnCode := EnterData(State,'U',36,10, 2,0,78,$87,[27]);
  125.   ReturnCode := EnterData(Zip,  'N',40,10, 5,0,78,$87,[27]);
  126.   ReturnCode := EnterData(SSN1, 'N',22,12, 3,0,95,$87,[27]);
  127.   ReturnCode := EnterData(SSN2, 'N',26,12, 2,0,95,$87,[27]);
  128.   ReturnCode := EnterData(SSN3, 'N',29,12, 4,0,95,$87,[27]);
  129.   {
  130.        EnterData() does not perform controlled I/O on Character data, so you
  131.      may need to write a little routine like GetChar(), or use this one.
  132.      The routine should be a function returning an integer, have a VAR
  133.      variable which will receive the entered character, and be able to tell
  134.      the difference between good data and an exit key.
  135.   }
  136.   ReturnCode := GetChar(Cash,  28,16,['X','x'],[#27]);
  137.   ReturnCode := GetChar(Check, 38,16,['X','x'],[#27]);
  138.   ReturnCode := GetChar(Charge,49,16,['X','x'],[#27]);
  139.   ReturnCode := GetChar(Each,  28,17,['X','x'],[#27]);
  140.   ReturnCode := GetChar(Box,   36,17,['X','x'],[#27]);
  141.   ReturnCode := GetChar(_Case, 45,17,['X','x'],[#27]);
  142.   GotoXY(1,1);
  143.   LowerInt   := 1;
  144.   UpperInt   := 144;
  145.   ReturnCode := EnterData(Quantity, 'I',22,18,6,0,80,$87,[27]);
  146.   LowerReal  := 0.50;
  147.   UpperReal  := 100.00;
  148.   ReturnCode := EnterData(Price,'R',38,18,6,2,80,$87,[27]);
  149.   LowerInt   := 0;
  150.   UpperInt   := 100;
  151.   ReturnCode := EnterData(Discount, 'I',22,19,2,0,80,$87,[27]);
  152.   Extension  := (Price * ((100 - Discount) / 100)) * Quantity;
  153.   GotoXY(22,20);
  154.   Write(Extension:8:2);
  155.   GotoXY(1,25);
  156.   Write('Again ? (Y/N) ');
  157.   Continue   := Upcase(ReadKey);
  158. Until Continue = 'N';
  159. End;
  160.  
  161. Begin
  162. ClrScr;
  163. MaxLimits;
  164.                         {** No screens defined in this demo **}
  165. MainLoop;
  166. TextBackground(Black);
  167. ClrScr;
  168. End.
  169.