[comp.lang.pascal] printing pascal runs..

cs211s65@uhccux.uhcc.hawaii.edu (Cs211s65) (09/27/89)

hello networld
I need some assistance with my programming class that I
am taking right now.. I am running Turbo pascal 3.02..(I know,
I know.. obsolete) BUT I need to know how to make the 
output of the run print to the printer rather than the
screen. That means all the Writeln and all that I type on 
the screen will go to the printer directly.. I currently
use the printscreen key on my IBM and it comes out looking
really ugly because of the overlaps and such.. any suggestions
are appreciated.. Thanks alot..
				Aloha and Mahalo!
				edman
Email me! cs211s65@uhccux.bitnet
 

ts@chyde.uwasa.fi (Timo Salmi LASK) (09/27/89)

In article <4930@uhccux.uhcc.hawaii.edu> cs211s65@uhccux.uhcc.hawaii.edu (Cs211s65) writes:
>hello networld
>I need some assistance with my programming class that I
>am taking right now.. I am running Turbo pascal 3.02..(I know,

First my apologies to the other netters for posting rather than
mailing a message discussing policy.  But it seems to me that while
the purpose of this area is discussing Pascal, and give in other
help in our programming problems, solving the students' programming
assignments is NOT what this area is about.

So students with assignments who read this.  Please think before you
post.  If you have genuine programming problems and solutions that
might *benefit* the net, then I guess it is ok. But do not expect us
to do your homework for you.

...................................................................
Prof. Timo Salmi                                (Site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: vakk::salmi Bitnet: salmi@finfun

wei@hpctdls.HP.COM (Bill Ives) (09/27/89)

     As I recall for TP 3, there is a compilier directive to
     force all Write/Writeln to go to standard devices (i.e.
     stdout, stdin, stderr, stdaux, stdprn, etc...). You should
     therefore try the PUT directive:
       {$P50}
     The 50 specifies an output buffer of 50 bytes ( make it what ever
     value you want )  Then you can redirect stdout to the printer
     from the command line when invoking your COM file like:
      program >LPT1
     This will redirect all write('') calls to the printer attached
     to LPT1.  Another way to do what you want is to actually modify the
     source code of the write statements to go to LST ( the list device ).
     Thus all write('Hello'); become write(LST,'Hello'); .
     I'm not real certain about either technic as its been a long time since
     I had to use TP 3.  Hope these suggestions work out....


     Bill Ives
     HP CTD
     #include <std-disclaimer-here>

ts@chyde.uwasa.fi (Timo Salmi LASK) (09/28/89)

In article <4930@uhccux.uhcc.hawaii.edu>
cs211s65@uhccux.uhcc.hawaii.edu (Cs211s65) writes:
::>hello networld
::>I need some assistance with my programming class that I
::>am taking right now.. I am running Turbo pascal 3.02..(I know,

ts@chyde.uwasa.fi writes:
:>So students with assignments who read this.  Please think before you
:>post.  If you have genuine programming problems and solutions that
:>might *benefit* the net, then I guess it is ok. But do not expect us
:>to do your homework for you.

In the case of cs211s65@uhccux.uhcc.hawaii.edu the request for help
was a very legitimate and a reasonable one.  I sincerely apologize
that this reflected on a wrong person.  My mistake, there.  The
issue, nevertheless, remains unchanged. 

...................................................................
Prof. Timo Salmi                                (Site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: vakk::salmi Bitnet: salmi@finfun

lihan@walt.cc.utexas.edu (Bruce Bostwick) (09/28/89)

In article <795@chyde.uwasa.fi> ts@chyde.uwasa.fi (Timo Salmi LASK) writes:
>In article <4930@uhccux.uhcc.hawaii.edu> cs211s65@uhccux.uhcc.hawaii.edu (Cs211s65) writes:
>>I need some assistance with my programming class that I
>
>First my apologies to the other netters for posting rather than
>mailing a message discussing policy.  But it seems to me that while
>the purpose of this area is discussing Pascal, and give in other
>help in our programming problems, solving the students' programming
>assignments is NOT what this area is about.
>

Actually, the solution to this problem isn't an assignment, but rather required
by class policy, at least in the Pascal courses I'm familiar with.  The course
requires a printout of the program listing, followed by a _printed copy_ of the
run results.  The question was how to generate that printed copy of the run.

As far as I know, there's no way to do that easily from turbo 3.0. The only
solution I know of is fairly unobvious, a really ugly kludge, and not at all
the sort of thing a CS student drilled in 'elegance at all costs' will be pre-
pared to think of.  One has to modify ALL the writeln's in the program, as
well as add a writeln after each readln, to simulate this 'printer echo' mode.
If you know a neat, elegant way to do that from 3.0, please enlighten us.
Otherwise, please don't be so quick to condemn 'homework on the net' -- not
all valid questions come from CS grad students!


=======================================================================
Internet:lihan@walt.cc.utexas.edu     Disclaimer: My employer doesn't
MaBellNet:(512)459-1602                    even know UseNet exists, let
SlowNet:varies chaotically,                alone that I'm on it and ex-
     e-mail for current value              pressing opinions ...
+---------------------------------------------------------------------+
                       (-:   a.k.a. BB/CIV   :-)
=======================================================================

bb16@prism.gatech.EDU (BOSTATER,Scott) (09/28/89)

For those of you who are still interested in the original question....

      How to send TP 3.0 writeln statements to the printer.

Why not try Ctrl-PrtScr? This will send all the screen output to the printer
until another Cntrl-PrtScr is pressed. It's not as fancy as using redirection
like TP 4.0/5.0/5.5 allows, but its quick, easy, requires no code re-writes,
and requires minimal keystrokes. :-)

As for doing homework on the net...
   
  I don't see whats wrong about for advice on the net, other than direct 
  requests for source code. To find new ideas or approaches to a subject,
  programming or otherwise, is what college *should* encourage. If the
  teacher cannot provide the necessary guidence because he's overworked,
  doesn't care, or doesn't know, the net would be a logical place to go
  for help. (ok, maybe a text book first, but who really reads them? :)

  Granted, nobody wants to see questions with syntax, basic programming
  techniques, etc. But questions dealing with OS specific functions,
  advanced programming techniques, and compiler specific functions/bugs
  should be fair game. The text I had way back when sure didn't mention
  anything about Cntrl-PrtScr. I'm not sure whether the TP manual mentions
  it either... :) 

  DISCLAIMER: My job is an education. Whenever I ask a question on the net,
              I'm asking for help with my "homework". The only difference is
              that I don't get credit for correct answers at the end of the
              quarter (my boss gets that :) I do, of course, get credit for
              incorrect answers....

So much for my $0.02 worth,


-- 
Scott Bostater      GTRI/RAIL/RAD   (Ga. Tech)
"My soul finds rest in God alone; my salvation comes from Him"  -Ps 62.1
uucp:     ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!bb16
Internet: bb16@prism.gatech.edu

pyoung@puppis.axion.bt.co.uk (Peter Young) (09/28/89)

If you are running Turbo V3.0 under CP/M , as I do on my clanky old
home computer, then you can get round this by using CP/M to redirect
the output to the printer. Saves having to replace all the writeln 
with writeln(lst,....).
Since the output no longer appears on the screen you have to remember
not to make any typing errors.
 
Don't know if there is a Domestos equivalent to this though.
  ____________________________________________________________________
  Pete Young                 pyoung@axion.bt.co.uk                     
  British Telecom Research Labs,SSTF, Martlesham Heath IPSWICH IP5 7RE
  Phone  +44 473 645054 

ts@chyde.uwasa.fi (Timo Salmi LASK) (09/28/89)

In article <18883@ut-emx.UUCP> lihan@walt.cc.utexas.edu (Bruce Bostwick) writes:
>In article <795@chyde.uwasa.fi> ts@chyde.uwasa.fi (Timo Salmi LASK) writes:
>>In article <4930@uhccux.uhcc.hawaii.edu> cs211s65@uhccux.uhcc.hawaii.edu (Cs211s65) writes:
>>>I need some assistance with my programming class that I

>As far as I know, there's no way to do that easily from turbo 3.0. The only
>solution I know of is fairly unobvious, a really ugly kludge, and not at all
>the sort of thing a CS student drilled in 'elegance at all costs' will be pre-
>pared to think of.  One has to modify ALL the writeln's in the program, as
>well as add a writeln after each readln, to simulate this 'printer echo' mode.
>If you know a neat, elegant way to do that from 3.0, please enlighten us.
>Otherwise, please don't be so quick to condemn 'homework on the net' -- not
>all valid questions come from CS grad students!

Although I am not amused with your imposing conditions on me on your
last three lines I shall try to consider constructively the original
problem of directing Turbo Pascal 3.0 screen output to the printer. 
Let us start from Turbo Pascal 4.0, though.  In 4.0 the solution is
very easy and goes like this:
   assign (output, 'prn'); 
   rewrite (output); All output is directed to the printer after
this.  In Turbo Pascal 3.02A this method does not work, but writing
all writeln two times is not necessary, either.  The well-known
trick around this problem is the following:

   (* put this at the beginning of your program *)
   const UsePrinter = true;  (* false for screen *)
   var str : string[255];

   procedure WRITEIT (s : str);
   var f : text;
   begin
     if UsePrinter then
       begin
         assign (f, 'prn');
         rewrite (f);
         writeln (f, s);
         (* flush (f);  if you experience problems *)
         close (f);
         (* writeln (s);  if you want it on the screen at the same time *)
       end
     else
       writeln (s);
   end; (* writeit *)

Then replace all the subsequent writeln commands in your program
with WRITEIT.  This solution has some features of a kludge, but it
is easy to apply and does not require much rewriting of the original
program.  If this is not satisfactory, then one would have to try to
write a resident program that intercepts the output directed to the
screen.  The LPTX.ARC facility has this kind of on idea, although it
intercepts file writes rather than screen writes and redirects them
to the printer. 

...................................................................
Prof. Timo Salmi                                (Site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: vakk::salmi Bitnet: salmi@finfun

filbo@gorn.santa-cruz.ca.us (Bela Lubkin) (09/29/89)

In article <4930@uhccux.uhcc.hawaii.edu> "edman" writes:
[how do I redirect Turbo 3.0 program output to the printer?]

  LstOutPtr:=ConOutPtr;

All output goes to the printer, so you better know what the prompts are (or
have an unbuffered dot-matrix printer where you can see what's happening).

And here is a very simple ConOutPtr procedure that sends output to both
devices...

Procedure ConAndLstOutput(C: Char);
  Var
    Regs: Record Case Integer Of
             8: (AL,AH,BL,BH,CL,CH,DL,DH: Byte);
            16: (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: Integer);
          End;
  Begin
    With Regs Do
     Begin
      AH:=2;  DL:=Byte(C);  MsDos(Regs);  { Console output }
      AH:=5;  DL:=Byte(C);  MsDos(Regs);  { Printer output }
     End;
  End;

Begin { Main program...}
  ConOutPtr:=Ofs(ConAndListOutput);
  ...

Bela Lubkin     * *   filbo@gorn.santa-cruz.ca.us   CIS: 73047,1112
     @        * *     ...ucbvax!ucscc!gorn!filbo    ^^^  REALLY slow [months]
R Pentomino     *     Filbo @ Pyrzqxgl (408) 476-4633 & XBBS (408) 476-4945

ts@chyde.uwasa.fi (Timo Salmi LASK) (09/30/89)

In article <41.filbo@gorn.santa-cruz.ca.us> filbo@gorn.santa-cruz.ca.us (Bela Lubkin) writes:
>In article <4930@uhccux.uhcc.hawaii.edu> "edman" writes:
>[how do I redirect Turbo 3.0 program output to the printer?]
>
>  LstOutPtr:=ConOutPtr;

   This is indeed a very neat solution to the problem in Turbo
Pascal 3.  I must admit that I did not come to think of it myself. 
   Just in case it confuses somebody, allow a minor correction.  It
should be the other way round, that is ConOutPtr := LstOutPtr;
   What happens here is that the pointers to the i/o drivers can be
changed in Turbo Pascal 3 using this method.  It takes effect when
the statement is first encountered.  So for some applications it
might be even placed elsewhere than at the beginning of the program. 
In fact, this redirection can be turned on and off by storing the
pointer to the i/o routine like this:
   var tmp : integer;
   :
   tmp := ConOutPtr;         (* store the original *)
   ConOutPtr := LstOutPtr;   (* redirect *)
   :
   :
   ConOutPtr := tmp;         (* again to screen *)
   :
...................................................................
Prof. Timo Salmi                                (Site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: vakk::salmi Bitnet: salmi@finfun