home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / database / edit_22 / editdemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-06-10  |  8.8 KB  |  209 lines

  1. Program EditDemo2;
  2.  
  3. (*  The following program demonstrates a fairly simple method of data entry. *)
  4.  
  5. {$V-}  (* Turn off string parameter checking (see manual) *)
  6.  
  7. Uses
  8.   CRT,Editor;
  9.  
  10. Var
  11.   Date       : String[8];     (* These could just as easily be a record type *)
  12.   FullName   : String[35];
  13.   Address    : String[35];
  14.   City       : String[30];
  15.   State      : String[2];
  16.   Zip        : String[5];
  17.   Phone      : String[8];
  18.   Purchase   : Real;
  19.  
  20.   Continue   : String[1];     (* Stand-alone entry variables *)
  21.   MenuSelect : LongInt;
  22. (* This is a quick-and-dirty method of providing for a "Main Menu". It could
  23.    just as easily be done using windowing techniques. *)
  24.  
  25. Procedure MainMenu;
  26. Begin
  27.   Color(Yellow,Blue);     (* Set the menu colors and draw the menu *)
  28.   gotoXY(20, 2); Write('┌───────────────────────────────────┐');
  29.   gotoXY(20, 3); Write('│            Main Menu              │');
  30.   gotoXY(20, 4); Write('├───────────────────────────────────┤');
  31.   gotoXY(20, 5); Write('│  1. Entry Screen 1                │');
  32.   gotoXY(20, 6); Write('│  2. Not used                      │');
  33.   gotoXY(20, 7); Write('│  3. Not used                      │');
  34.   gotoXY(20, 8); Write('│  4. Not used                      │');
  35.   gotoXY(20, 9); Write('│  5. Exit Demo                     │');
  36.   gotoXY(20,10); Write('│                                   │');
  37.   gotoXY(20,11); Write('└───────────────────────────────────┘');
  38.  
  39.     (* After displaying the menu, change the colors and display a single entry
  40.        data selection block.  Note that it is a numeric (integer) entry and
  41.        doesn't require the Enter key be pressed. *)
  42.  
  43.   Color(Yellow,Black);
  44.   gotoXY(27,13); Write('Enter Selection:');
  45.   EditInt(MenuSelect,1,44,13,15,0);
  46.   ClrScr;
  47. End;
  48.  
  49. (* This procedure merely draws the data entry screen.  Note that a slightly
  50.    different method is used from the menu procedure: the basic screen is
  51.    drawn first with the field descriptions overlaid on the screen.  This
  52.    allows easier "fine-tuning" of the field description placement. *)
  53.  
  54. Procedure EntryScr;
  55. Begin
  56.   Color(Blue,Cyan);  (* Set the entry screen color *)
  57.   gotoXY(1,1);
  58.   Write('┌──────────────────────────────────────────────────────────────────────────────┐');
  59.   Write('│                                                                              │');
  60.   Write('│                                                                              │');
  61.   Write('│                                                                              │');
  62.   Write('│                                                                              │');
  63.   Write('│                                                                              │');
  64.   Write('│                                                                              │');
  65.   Write('│                                                                              │');
  66.   Write('│                                                                              │');
  67.   Write('│                                                                              │');
  68.   Write('├──────────────────────────────────────────────────────────────────────────────┤');
  69.   Write('│                                                                              │');
  70.   Write('│                                                                              │');
  71.   Write('└──────────────────────────────────────────────────────────────────────────────┘');
  72.  
  73.     (* Overlay the screen and field descriptions on the pre-drawn screen *)
  74.  
  75.   gotoXY(26, 1); Write('[ Data Editor Demonstration ]');
  76.   gotoXY(32,11); Write('[ Instructions ]');
  77.   gotoXY(57,14); Write('[ COMPUsystems N.W. ]');
  78.   gotoXY(51, 2); Write('Invoice Date :   /  /');
  79.   gotoXY(5 , 3); Write('Full Name :');
  80.   gotoXY(7 , 5); Write('Address :');
  81.   gotoXY(10, 7); Write('City :');
  82.   gotoXY(50, 7); Write('State :');
  83.   gotoXY(61, 7); Write('Zip :');
  84.   gotoXY(9 , 9); Write('Phone :    -');
  85.   gotoXY(40, 9); Write('Purchase Amount : $');
  86. End;
  87.  
  88.               (*  This is the actual input procedure  *)
  89.  
  90. Procedure NewInput;
  91. Begin
  92.   FieldNo   := 1;        (* Begin with field 1.  This can be any number
  93.                             between 1 and LastField and provides the
  94.                             default "first" data field to be entered. *)
  95.   LastField := 8;        (* This is the last field to be entered.  Once
  96.                             the Enter key is pressed, data entry is
  97.                             complete. *)
  98.   Date      := '';       (* Initialize the entry variables. *)
  99.   FullName  := '';
  100.   Address   := '';
  101.   City      := '';
  102.   State     := '';
  103.   Zip       := '';
  104.   Phone     := '   -';   (* Note the "-" in the phone number field. *)
  105.   Purchase  := 0.0;
  106.  
  107.   (* The "Repeat - Until" loop allows the data entry operator to skip around
  108.      on the screen and enter or revise data at choice. *)
  109.  
  110.   Repeat
  111.     Case FieldNo of
  112.       1 : Begin
  113.                  (* The first three lines merely demonstrate an instruction
  114.                     display for the operator, and are not necessary for the
  115.                     actual data entry. *)
  116.            Color(Red,Cyan);              (* Set instruction color *)
  117.            gotoXY(2,12); Write('':78);   (* Clear the instruction line *)
  118.                                          (* Write the instruction *)
  119.            gotoXY(5,12); Write('Enter Invoice date in MM/DD/YY format');
  120.                   (* Enter/revise a date field *)
  121.            EditDate(Date,66,2,Black,Cyan);
  122.           End;
  123.       2 : Begin
  124.            Color(Red,Cyan);
  125.            gotoXY(2,12); Write('':78);
  126.            gotoXY(5,12); Write('Enter Purchaser''s FULL name');
  127.            EditString(FullName,35,17,3,Black,Cyan,'        ');
  128.           End;
  129.       3 : Begin
  130.            Color(Red,Cyan);
  131.            gotoXY(2,12); Write('':78);
  132.            gotoXY(5,12); Write('Enter full street address');
  133.            EditString(Address,35,17,5,Black,Cyan,'        ');
  134.           End;
  135.       4 : Begin
  136.            Color(Red,Cyan);
  137.            gotoXY(2,12); Write('':78);
  138.            gotoXY(5,12); Write('Enter City name');
  139.            EditString(City,30,17,7,Black,Cyan,'        ');
  140.           End;
  141.       5 : Begin
  142.            Color(Red,Cyan);
  143.            gotoXY(2,12); Write('':78);
  144.            gotoXY(5,12); Write('Enter 2 character State name');
  145.            EditString(State,2,58,7,Black,Cyan,'UU');
  146.           End;
  147.       6 : Begin
  148.            Color(Red,Cyan);
  149.            gotoXY(2,12); Write('':78);
  150.            gotoXY(5,12); Write('Enter 5 digit Zip Code');
  151.            EditString(Zip,5,67,7,Black,Cyan,'#####');
  152.           End;
  153.       7 : Begin
  154.            Color(Red,Cyan);
  155.            gotoXY(2,12); Write('':78);
  156.            gotoXY(5,12); Write('Enter NUMERIC telephone number');
  157.            EditString(Phone,8,17,9,Black,Cyan,'###*####');
  158.           End;
  159.       8 : Begin
  160.            Color(Red,Cyan);
  161.            gotoXY(2,12); Write('':78);
  162.            gotoXY(5,12); Write('Enter TOTAL purchase amount');
  163.            EditReal(Purchase,7,59,9,2,Black,Cyan)
  164.           End;
  165.     End; { Case }
  166.   Until FieldNo > LastField;   (* If the Enter key is pressed on the last
  167.                                   field, then we're done. *)
  168.   gotoXY(2,12); Write('':78);  (* Clear the last instruction *)
  169.   Color(14,0);                 (* Change the colors *)
  170.  
  171.     (* A stand-alone choice field *)
  172.  
  173.   gotoXY(20,17); Write('Enter another record (Y/N)?');
  174.   EditChoice(Continue,49,17,'Y','N',Yellow,Black);
  175.  
  176.     (* Clear the screen for rewrite, regardless of the choice *)
  177.  
  178.   ClrScr;
  179. End;
  180.  
  181. (* This is the mainline.  Note the nested loops could be separate procedures,
  182.    but this is a little simpler. *)
  183.  
  184. Begin
  185.   Color(14,0);                          (* Initialize the screen color *)
  186.   Clrscr;                               (* Clear the screen *)
  187.   Repeat                                (* The first loop *)
  188.     MenuSelect := 0;                    (* Re-initialize variable each time *)
  189.     MainMenu;                           (* Display the main menu *)
  190.     Case MenuSelect of                  (* The "case" loop *)
  191.          1 : Repeat                     (* The data screen loop *)
  192.                ClrScr;
  193.                EntryScr;
  194.                NewInput;
  195.              Until Continue = 'N';      (* End data entry loop *)
  196.       2..4 : Begin
  197.                Color(14,0); Clrscr;
  198.                gotoXY(20,5);
  199.                Write('*** This selection is not used ***');
  200.                Delay(2000); Clrscr;
  201.              End;
  202.          5 : Begin                      (* Leave a message *)
  203.                Color(14,0); Clrscr;
  204.                gotoXY(20,5);
  205.                Write('End of Data Editor Demonstration');
  206.               End;
  207.     End; { Case }                       (* End the "case" loop *)
  208.   Until MenuSelect = 5;                 (* then the first loop *)
  209. End.