Program PTOOLENT;  {Copyright  R D Ostrander
                               Ostrander Data Services
                               5437 Honey Manor Dr
                               Indianapolis  IN  46241

     This is a demonstration program for the Turbo Pascal subroutine PTOOLENT
     for intelligent field editting. Address any questions to the author at
     the above address.                                                      }

{ $ C - } { This parameter is optional - the PTOOLENT subroutine will identify
            and report Ctrl-Break during field editting.                      }

{$V-}     { This parameter is necessary in order to pass String parameters
            of other than 80 characters.                                   }

Var

    Data      : String [80];                { Data to be editted }
    DataI     : Integer     absolute Data;
    DataR     : Real        absolute Data;
    Size      : Integer;                    { Size of Data              }
    Decimals  : Integer;                    { Number of Decimal places  }
    RetCode   : Integer;                    { Return Code from PTOOLENT }
    DataType  : Char;                       { Type of data to edit      }


{$I PTOOLENT.INC}  {Include statement for PTOOLENT procedure}


BEGIN

     ClrScr;
     Gotoxy (15,5); Write ('Demonstration of PTOOLENT procedure.');
     Gotoxy (15,7); Write ('PTOOLENT and this program are copyrights');
     Gotoxy (15,8); Write ('of R D Ostrander');
     Gotoxy (15,9); Write ('   Ostrander Data Services');
     Gotoxy (15,10); Write ('   5437 Honey Manor Dr');
     Gotoxy (15,11); Write ('   Indianapolis  IN  46241');
     Gotoxy (15,13); Write ('and have been placed in the public domain.');
     Delay (5000);
     ClrScr;
     RetCode := 0;
     DataType := ' ';
     While (DataType <> 'X')                  { Main Program Loop }
       and (RetCode <> 79)   do
           Begin
                Gotoxy (5, 2);
                Write ('What type of data would you like to test?  ');
                Gotoxy (5, 3);
                Write ('S = String');
                Gotoxy (5, 4);
                Write ('I = Integer');
                Gotoxy (5, 5);
                Write ('R = Real');
                Gotoxy (5, 6);
                Write ('X = Exit');
                While (DataType <> 'S')           { Get Data Type to Edit }
                  and (DataType <> 'I')
                  and (DataType <> 'R')
                  and (DataType <> 'X') do
                      Begin
                           Gotoxy (47, 2);
                           Read (KBD, DataType);
                           Write (DataType);
                           DataType := UpCase (DataType);
                      End;
                If DataType <> 'X' then         { If 'X' then stop }
                   Begin
                        Size := 0;
                        Gotoxy (5, 8);
                        Write ('What size display area?      (1 thru 80)');
                        Gotoxy (34, 9);
                        Write ('(Press  End  to Exit)');
                        Gotoxy (30, 8);
                        While ((Size < 1)                { Get Size }
{ Note that these 2 }      or  (Size > 80))
{ Inquiries use the }     and (RetCode <> 79) do
{ PTOOLENT routine! }         PTOOLENT (Size, 'I', 2, 0, RetCode);
                        Gotoxy (5, 11);
                        Decimals := 0;
                        If (DataType = 'R')         { If Real get Decimals }
                       and (RetCode <> 79) then
                           Begin
                                Write ('How many decimal places? ');
                                PTOOLENT (Decimals, 'I', 2, 0, RetCode);
                           End
                           else ClrEol;
                        If RetCode <> 79 then
                           Begin
                                Gotoxy (1, 14);
                                Write ('Editting area below:');
{ Put in some test data }       Case DataType of
                                     'S' : Data  := 'ABCDEF';
                                     'I' : DataI := 12345;
                                     'R' : DataR := 1.23456789;
                                     End; {Case}
                                Gotoxy (1, 16);
                                ClrEol;
{ Set to Low Video for effect } LowVideo;
{ Do the edit }                 PTOOLENT (Data, DataType, Size, Decimals,
                                          RetCode);
{ Return to Normal }            NormVideo;
                                Gotoxy (1, 19);
{ Display the results }         Write ('Output is: ');
                                ClrEol;
                                Case DataType of
                                     'S' : Write ('(', Data, ')');
                                     'I' : Write ('(', DataI:Size, ')');
                                     'R' : Write ('(', DataR:Size:Decimals,
                                                  ')');
                                     End; {Case}
                                Gotoxy (1, 20);
                                ClrEol;
                                Write ('Data Type is: ', DataType);
                                Gotoxy (1, 21);
                                ClrEol;
                                Write ('Size is: ', Size);
                                If DataType = 'R' then
                                   Write ('.', Decimals);
                                Gotoxy (1, 22);
                                ClrEol;
                                Write ('Return Code is: ', RetCode);
                                DataType := ' ';
                                RetCode := 0;
                           End;
                   End;

           End;
     Gotoxy (1,24);
END.
