PROGRAM SAMPLE5; { SnapShot Demonstration }

  USES Crt, TPlus, TPWindow;
{ This program will take a "snapshot" of the current screen and save/restore
  it.  Although it is not shown in this sample program it is possible to
  perform multiple nested snapshots with the NestSnap procedure.

{ This program requires IBM or compatible hardware. }

  CONST
    Save: INTEGER = 1;
    Saveclear: INTEGER = 2;
    Restore: INTEGER = 3;

  VAR
    Index: INTEGER;
    Scan: BYTE;
    Answer: String1;

  BEGIN
    { Fill the screen for the purpose of demonstration }
    FOR Index := 1 TO 19 DO
      WRITELN('****   This line is used to fill up your screen   ****');

    WRITELN;
    WRITELN(
      'If you would like a snapshot demonstration before continuing enter "Y"'
            );
    repeat
      ReadKb(Scan, Answer);
      Answer[1] := UPCASE(Answer[1]);
    until answer[1] in ['Y', 'N'];
    IF Answer = 'Y' THEN
      BEGIN
         { Take a snapshot of the current screen and cursor position
           and clear the screen afterward.  When cleared, cursor is placed
           in the upper left corner. }

        SNAPSHOT(SaveClear);

         { Now display a new message.  The SaveClear (3) option also
           places the cursor in the upper left hand corner of the screen. }

        FastWrite('Your Screen Has Just Been Saved and Cleared.', white,
                  black, 1);

        GOTOXY(10, 7);
        FastWrite('Press any key to restore previous screen....', cyan, black,
                  1);
        PauseKb;

        { Now restore the screen and cursor where it was before the Save }
        SNAPSHOT(Restore);
      END;

    WRITELN('Press any key to end program');
    PauseKb;
  END.
