Program PTOOLWIN;  {Copyright  R D Ostrander
                               Ostrander Data Services
                               5437 Honey Manor Dr
                               Indianapolis  IN  46241

     This is a demonstration program for the Turbo Pascal subroutine PTOOLWIN
     for window manipulations. Address any questions to the author at the
     above address.                                                          }


{$I PTOOLWIN.INC}  {Include statement for PTOOLWIN functions and parameters }

VAR

   ScreenType, Ans : Char;


{ Internal Routines Begin Here ****************************** }


Procedure NewScreen;

Var
   Screen, Code : Integer;

Begin
     Val (Ans, Screen, Code);
     If (Code = 0) and
        (Screen in [1..9]) then
        If PTOOLWIN_Stack_Size = 9 then
           Begin
                PTWOpen (10);
                ClrScr;
                Gotoxy (20,1);
                Write ('This demonstration program only allows 9 windows.');
                Gotoxy (20,3);
                Write ('I will now close the previous window');
                Delay (3000);
                PTWClose;
                PTWClose;
           End
        else
           Begin
                PTWOpen (Screen);
                ClrScr;
           End;
End;


{ Main Program Begins Here ********************************** }


BEGIN

 ClrScr;
 Gotoxy (15,7); Write ('Demonstration of PTOOLWIN procedure.');
 Gotoxy (15,9); Write ('PTOOLWIN and this program are copyrights');
 Gotoxy (15,10); Write ('of R D Ostrander');
 Gotoxy (15,11); Write ('   Ostrander Data Services');
 Gotoxy (15,12); Write ('   5437 Honey Manor Dr');
 Gotoxy (15,13); Write ('   Indianapolis  IN  46241');
 Gotoxy (15,14); Write ('and have been placed in the public domain.');

 ScreenType := ' ';
 Ans        := ' ';

 Gotoxy (10,19);
 Write ('Are you using a Monochrome card or Color/Graphics card ? (M/C)');
 Gotoxy (10,20);
 Write ('Compaq uses a Color/Graphics - 3270/PC uses Monochrome!       ');
 While not (Ans in ['M', 'C']) do
       Begin
            Read (KBD, Ans);
            Write (Ans);
            Ans := UpCase (Ans);
       End;
 PTOOLWIN_Screen_Type := Ans;
 Ans := ' ';

 Gotoxy (10,23);
 Write ('Would you like to have this program run in Color? (Y/N)');
 Gotoxy (10,24);
 Write ('Some Monochrome cards will show shades of grey.        ');
 While not (ScreenType in ['Y', 'N']) do
       Begin
            Read (KBD, ScreenType);
            Write (ScreenType);
            ScreenType := UpCase (ScreenType);
       End;

 If ScreenType = 'Y' then
    Begin
         PTWSet (1, 2, 3, 31, 9, 1, 0, 15);
         PTWSet (2, 7, 4, 73, 21, 2, 1, 14);
         PTWSet (3, 40, 1, 80, 25, 0, 2, 13);
         PTWSet (4, 1, 8, 80, 16, -1, 3, 12);
         PTWSet (5, 8, 12, 55, 24, -2, 4, 7);
         PTWSet (6, 1, 10, 45, 20, 1, 5, 12);
         PTWSet (7, 5, 5, 75, 10, 2, 6, 9);
         PTWSet (8, 40, 11, 70, 24, 0, 15, 0);
         PTWSet (9, 1, 1, 80, 25, -2, 1, 10);
         PTWSet (10, 1, 21, 80, 25, -2, 4, 0);
    End
 else
    Begin
         PTWSet (1, 2, 3, 31, 9, 0, 15, 0);
         PTWSet (2, 7, 4, 73, 21, 1, 0, 15);
         PTWSet (3, 40, 1, 80, 25, 2, 0, 15);
         PTWSet (4, 1, 8, 80, 16, -1, 0, 15);
         PTWSet (5, 8, 12, 55, 24, -2, 0, 15);
         PTWSet (6, 1, 10, 45, 20, 1, 15, 0);
         PTWSet (7, 5, 5, 75, 10, 2, 0, 15);
         PTWSet (8, 40, 11, 70, 24, -1, 0, 15);
         PTWSet (9, 1, 1, 80, 25, -2, 0, 15);
         PTWSet (10, 1, 21, 80, 25, 2, 15, 0);
    End;

 While Ans <> 'E'do
       Begin
            If Ans <> 'C' then
               Begin
                    Gotoxy (2,2); Write ('Pick a screen - 1 to 9');
                    Gotoxy (2,3); Write (' or "C" to close a screen');
                    Gotoxy (2,4); Write (' or "E" to End           ');
               End;
            Read (KBD, Ans);
            Write (Ans); Gotoxy (WhereX - 1, WhereY);
            Ans := UpCase (Ans);
            If (Ans = 'C') and (PTOOLWIN_Stack_Size > 0) then PTWClose;
            If Ans in ['1'..'9'] then NewScreen;
       End;

Window (1,1,80,25);
ClrScr;
Gotoxy (1,24);
TextColor(0);
TextBackground (15);

END.