home *** CD-ROM | disk | FTP | other *** search
- Program EditDemo2;
-
- (* The following program demonstrates a fairly simple method of data entry. *)
-
- {$V-} (* Turn off string parameter checking (see manual) *)
-
- Uses
- CRT,Editor;
-
- Var
- Date : String[8]; (* These could just as easily be a record type *)
- FullName : String[35];
- Address : String[35];
- City : String[30];
- State : String[2];
- Zip : String[5];
- Phone : String[8];
- Purchase : Real;
-
- Continue : String[1]; (* Stand-alone entry variables *)
- MenuSelect : LongInt;
- (* This is a quick-and-dirty method of providing for a "Main Menu". It could
- just as easily be done using windowing techniques. *)
-
- Procedure MainMenu;
- Begin
- Color(Yellow,Blue); (* Set the menu colors and draw the menu *)
- gotoXY(20, 2); Write('┌───────────────────────────────────┐');
- gotoXY(20, 3); Write('│ Main Menu │');
- gotoXY(20, 4); Write('├───────────────────────────────────┤');
- gotoXY(20, 5); Write('│ 1. Entry Screen 1 │');
- gotoXY(20, 6); Write('│ 2. Not used │');
- gotoXY(20, 7); Write('│ 3. Not used │');
- gotoXY(20, 8); Write('│ 4. Not used │');
- gotoXY(20, 9); Write('│ 5. Exit Demo │');
- gotoXY(20,10); Write('│ │');
- gotoXY(20,11); Write('└───────────────────────────────────┘');
-
- (* After displaying the menu, change the colors and display a single entry
- data selection block. Note that it is a numeric (integer) entry and
- doesn't require the Enter key be pressed. *)
-
- Color(Yellow,Black);
- gotoXY(27,13); Write('Enter Selection:');
- EditInt(MenuSelect,1,44,13,15,0);
- ClrScr;
- End;
-
- (* This procedure merely draws the data entry screen. Note that a slightly
- different method is used from the menu procedure: the basic screen is
- drawn first with the field descriptions overlaid on the screen. This
- allows easier "fine-tuning" of the field description placement. *)
-
- Procedure EntryScr;
- Begin
- Color(Blue,Cyan); (* Set the entry screen color *)
- gotoXY(1,1);
- Write('┌──────────────────────────────────────────────────────────────────────────────┐');
- Write('│ │');
- Write('│ │');
- Write('│ │');
- Write('│ │');
- Write('│ │');
- Write('│ │');
- Write('│ │');
- Write('│ │');
- Write('│ │');
- Write('├──────────────────────────────────────────────────────────────────────────────┤');
- Write('│ │');
- Write('│ │');
- Write('└──────────────────────────────────────────────────────────────────────────────┘');
-
- (* Overlay the screen and field descriptions on the pre-drawn screen *)
-
- gotoXY(26, 1); Write('[ Data Editor Demonstration ]');
- gotoXY(32,11); Write('[ Instructions ]');
- gotoXY(57,14); Write('[ COMPUsystems N.W. ]');
- gotoXY(51, 2); Write('Invoice Date : / /');
- gotoXY(5 , 3); Write('Full Name :');
- gotoXY(7 , 5); Write('Address :');
- gotoXY(10, 7); Write('City :');
- gotoXY(50, 7); Write('State :');
- gotoXY(61, 7); Write('Zip :');
- gotoXY(9 , 9); Write('Phone : -');
- gotoXY(40, 9); Write('Purchase Amount : $');
- End;
-
- (* This is the actual input procedure *)
-
- Procedure NewInput;
- Begin
- FieldNo := 1; (* Begin with field 1. This can be any number
- between 1 and LastField and provides the
- default "first" data field to be entered. *)
- LastField := 8; (* This is the last field to be entered. Once
- the Enter key is pressed, data entry is
- complete. *)
- Date := ''; (* Initialize the entry variables. *)
- FullName := '';
- Address := '';
- City := '';
- State := '';
- Zip := '';
- Phone := ' -'; (* Note the "-" in the phone number field. *)
- Purchase := 0.0;
-
- (* The "Repeat - Until" loop allows the data entry operator to skip around
- on the screen and enter or revise data at choice. *)
-
- Repeat
- Case FieldNo of
- 1 : Begin
- (* The first three lines merely demonstrate an instruction
- display for the operator, and are not necessary for the
- actual data entry. *)
- Color(Red,Cyan); (* Set instruction color *)
- gotoXY(2,12); Write('':78); (* Clear the instruction line *)
- (* Write the instruction *)
- gotoXY(5,12); Write('Enter Invoice date in MM/DD/YY format');
- (* Enter/revise a date field *)
- EditDate(Date,66,2,Black,Cyan);
- End;
- 2 : Begin
- Color(Red,Cyan);
- gotoXY(2,12); Write('':78);
- gotoXY(5,12); Write('Enter Purchaser''s FULL name');
- EditString(FullName,35,17,3,Black,Cyan,' ');
- End;
- 3 : Begin
- Color(Red,Cyan);
- gotoXY(2,12); Write('':78);
- gotoXY(5,12); Write('Enter full street address');
- EditString(Address,35,17,5,Black,Cyan,' ');
- End;
- 4 : Begin
- Color(Red,Cyan);
- gotoXY(2,12); Write('':78);
- gotoXY(5,12); Write('Enter City name');
- EditString(City,30,17,7,Black,Cyan,' ');
- End;
- 5 : Begin
- Color(Red,Cyan);
- gotoXY(2,12); Write('':78);
- gotoXY(5,12); Write('Enter 2 character State name');
- EditString(State,2,58,7,Black,Cyan,'UU');
- End;
- 6 : Begin
- Color(Red,Cyan);
- gotoXY(2,12); Write('':78);
- gotoXY(5,12); Write('Enter 5 digit Zip Code');
- EditString(Zip,5,67,7,Black,Cyan,'#####');
- End;
- 7 : Begin
- Color(Red,Cyan);
- gotoXY(2,12); Write('':78);
- gotoXY(5,12); Write('Enter NUMERIC telephone number');
- EditString(Phone,8,17,9,Black,Cyan,'###*####');
- End;
- 8 : Begin
- Color(Red,Cyan);
- gotoXY(2,12); Write('':78);
- gotoXY(5,12); Write('Enter TOTAL purchase amount');
- EditReal(Purchase,7,59,9,2,Black,Cyan)
- End;
- End; { Case }
- Until FieldNo > LastField; (* If the Enter key is pressed on the last
- field, then we're done. *)
- gotoXY(2,12); Write('':78); (* Clear the last instruction *)
- Color(14,0); (* Change the colors *)
-
- (* A stand-alone choice field *)
-
- gotoXY(20,17); Write('Enter another record (Y/N)?');
- EditChoice(Continue,49,17,'Y','N',Yellow,Black);
-
- (* Clear the screen for rewrite, regardless of the choice *)
-
- ClrScr;
- End;
-
- (* This is the mainline. Note the nested loops could be separate procedures,
- but this is a little simpler. *)
-
- Begin
- Color(14,0); (* Initialize the screen color *)
- Clrscr; (* Clear the screen *)
- Repeat (* The first loop *)
- MenuSelect := 0; (* Re-initialize variable each time *)
- MainMenu; (* Display the main menu *)
- Case MenuSelect of (* The "case" loop *)
- 1 : Repeat (* The data screen loop *)
- ClrScr;
- EntryScr;
- NewInput;
- Until Continue = 'N'; (* End data entry loop *)
- 2..4 : Begin
- Color(14,0); Clrscr;
- gotoXY(20,5);
- Write('*** This selection is not used ***');
- Delay(2000); Clrscr;
- End;
- 5 : Begin (* Leave a message *)
- Color(14,0); Clrscr;
- gotoXY(20,5);
- Write('End of Data Editor Demonstration');
- End;
- End; { Case } (* End the "case" loop *)
- Until MenuSelect = 5; (* then the first loop *)
- End.