community.borland.com

Article #15369: Printing the Run of a Program

 Technical Information Database

TI369D.txt - Printing the Run of a Program

Category   :Turbo Pascal
Platform   :All-32Bit
Product    :All32Bit,   

Description:

Educators teaching structured programming in PASCAL often require
students to submit a printout of the "Run" of assigned programs.
The "Run" represents the output of the program as it normally
appears on screen.  In mainframe environments, printing the "Run"
is nothing unusual.  Time and access are often very limited in
academic computer rooms and such a printout can be useful when
correcting code off-line.

The Integrated Development Environment of Turbo Pascal has no
provision for printing the "Run" of a program.  On a personal
computer, output may take a variety of forms; simple text,
graphics, sound etc.  Printing a "run" in the fashion of an
academic mainframe is only relevant to code producing simple text
as output.  More substantial programs involving color and
graphics must use other means to print the "run". Techniques
dealing with graphics and color are not addressed in this
document.

Printing the Run Using the DOS Version of Turbo Pascal

In DOS, the operating system is capable of echoing to printer
characters sent to the screen.  This feature only functions from
the DOS prompt and only for Turbo Pascal programs not using CRT
or GRAPH units.  The echoing function is toggled on and off with
the key sequence .

1.   Set the destination of the compiler to disk via the
       Compile|Destination menu selection.
2.   Compile the program.  Doing so will generate a .EXE file.
3.   Exit Turbo Pascal.
4.   Ensure your printer is on and on-line.
5.   At a DOS prompt, hold down the key marked  and
       press the letter "P". Then let up on both keys.
6.   Type the name of your program.  Do not include the three
       letter extension.  For instance, the program TEST.PAS
       is taken as just TEST. Screen and printer output will
       occur simultaneously.
7.   When the program is done, hold down the key marked 
       and press the letter "L". Then let up on both keys.
       Next hold down  again and press the letter "P".
       Let up on both keys.

Printing the Run Using the Windows Version of Turbo Pascal

Turbo Pascal for Windows is not ideally suited for introductory
Computer Science coursework.  Such coursework normally relies on
some terminal-type interface being involved.  Windows by its very
nature suspends all terminal-like devices available when running
DOS alone.  It is designed to function exclusively in an event-
driven, graphical environment.  Display functions are provided by
Windows and not by Turbo Pascal.  Hence, standard PASCAL
statements such as Write and Writeln do not function with the
screen display as they do with the DOS version. For Computer
Science coursework, it is strongly recommended that the DOS
version of Turbo Pascal be used.

A unit called WinCRT ships with Turbo Pascal for Windows.  This
unit causes an output window to be displayed when the statements
Write, Writeln, Read, or Readln are used.  It mimics the function
of a terminal device and serves as a temporary aid for those
learning to use Windows API functions.  This unit allows some
traditional programming to be done but provides nothing to
"print" a run.

If printing the output of a program in Windows is absolutely
required, follow these steps.

1.   Run the program.
2.   Enlarge the output window to fill the entire screen.
3.   Press the  key.  The  key
     will copy the contents of the Windows Desktop to the
     clipboard.
4.   Bring up the Windows Paintbrush program.
5.   Create an image large enough to hold the most of the
       screen.  See Microsoft Windows documentation for
       details.
6.   Using the Edit|Paste command, copy the contents of the
       clipboard into the image used by PaintBrush.
7.   To print, use the PaintBrush's printing commands as
       detailed in the Microsoft Windows documentation.

This method will only print the visible portion of the Window.
If program output has scrolled from view, it may need to be
scrolled back into view and the screen again copied to the
clipboard, copied from there to Paintbrush and then printed.  For
programs with significant output, this process may need to be
repeated many times.


Reference:
 

4/22/99 12:40:58 PM
 

Last Modified: 01-SEP-99