Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!cs.utexas.edu!uunet!mcsun!sunic!tut!ra!chyde!ts From: ts@chyde.uwasa.fi (Timo Salmi LASK) Newsgroups: comp.lang.pascal Subject: Re: printing pascal runs.. Keywords: help me.. help me.. Message-ID: <800@chyde.uwasa.fi> Date: 28 Sep 89 13:57:50 GMT References: <4930@uhccux.uhcc.hawaii.edu> <795@chyde.uwasa.fi> <18883@ut-emx.UUCP> Reply-To: ts@chyde.uwasa.fi (Timo Salmi LASK) Organization: U of Vaasa, Finland Lines: 58 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