Board index » delphi » Printing with LST

Printing with LST

I am using tp7 dos
I have a procedure that I need t give a user an option to print to the
screen or the printer. I was wondering if i could do this writing one
procedure.
I could write two. one with

writln ('blah')

and one with

writeln (LST,' blah);

but that would be inefficient. How could I set it up so that it makes a
decition on where to print. It could also be done like this.

if PrintToScreen
        then writeln ('Blah');
        else writeln (lst,'Blah');

but that is very ineffincient to. can anyone help?

thank you

-mike

 

Re:Printing with LST


On 11 Feb 1998 02:51:47 GMT, <dski...@erols.com> wrote:

Quote
>I am using tp7 dos
>I have a procedure that I need t give a user an option to print to the
>screen or the printer. I was wondering if i could do this writing one
>procedure.
>I could write two. one with

>writln ('blah')

>and one with

>writeln (LST,' blah);

>but that would be inefficient. How could I set it up so that it makes a
>decition on where to print. It could also be done like this.

>if PrintToScreen
>    then writeln ('Blah');
>    else writeln (lst,'Blah');

>but that is very ineffincient to. can anyone help?

>thank you

>-mike

Program Test;

Var OutFile : Text;

Begin
   Assign  (OutFile, '');
   Rewrite (OutFile);
   WriteLn (OutFile, 'This is a test');
End.

This will print to the screen.  If you assign OutFile to the printer
it will print there.  Hope this is enough to get you started.

Dennis D. Powers
PC/POLL SYSTEMS
Dennis.removet...@pcpoll.com

Support the anti-Spam amendment
Join at http://www.cauce.org/

Re:Printing with LST


JRS:  In article <01bd3697$c13ffe00$94f1accf@dskippy> of Wed, 11 Feb
1998 02:51:47 in comp.lang.pascal.misc, dski...@erols.com wrote:

Quote
>I am using tp7 dos

In that case, it is quite inappropriate to ask in c.l.p.misc -
c.l.p.borland is the place.

Quote
>I have a procedure that I need t give a user an option to print to the
>screen or the printer. I was wondering if i could do this writing one
>procedure.
>I could write two. one with
>writln ('blah')
>and one with
>writeln (LST,' blah);
>but that would be inefficient. How could I set it up so that it makes a
>decition on where to print. It could also be done like this.
>if PrintToScreen
>       then writeln ('Blah');
>       else writeln (lst,'Blah');
>but that is very ineffincient to. can anyone help?

Use just   Writeln(F, 'blah') ;   with   var F : text ;   and
Assign(F, S) ; Rewrite(F) ; ... ... ... Close(F) ;  where S is a file
name or device name provided by the user.

AFAIR, the effect of S=LST or S=PRN will not be quite the same in all
respects as those of using PRINTER.TPU's Lst for F; see manuals in case
it matters to you, which it probably will not.

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web <URL: http://www.merlyn.demon.co.uk/> - TP/BP/&c. FAQqish topics & links.
  Timo's TurboPascal <A HREF="ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip">FAQ</A>.
  <A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">Mini-FAQ</A> of c.l.p.b.

Re:Printing with LST


On 11 Feb 1998 02:51:47 GMT, <dski...@erols.com> wrote:

Quote
>I am using tp7 dos
>I have a procedure that I need t give a user an option to print to the
>screen or the printer. I was wondering if i could do this writing one
>procedure.
>I could write two. one with

>writln ('blah')

>and one with

>writeln (LST,' blah);

>but that would be inefficient. How could I set it up so that it makes a
>decition on where to print. It could also be done like this.

>if PrintToScreen
>    then writeln ('Blah');
>    else writeln (lst,'Blah');

>but that is very ineffincient to. can anyone help?

So IMHO the best way to do it, is to write a substitute for
write/writeln...

Here is whar I'm using in such cases:

...
var printit:boolean;
...

procedure cwrite(s:string);
begin
  if printit then
    write(lst,s)
  else
    write(s);
end;

this has the following advantage:

*You may decide if something goes to the printer or screen without
assign/reset/close constructs.
*You may include an IO-check for the LST-output and create your own
error messages..

It also has one disadvantages:

* You can only write strings (no more write('Hello',anyvar,' xxx');)

If you "export" this to a unit you can use it in various progs without
the mentioned open/close overhead....

Hope this helps...
Roman Gruber
------------> grub...@kapsch.net
"Every finished, working program is outdated"

Other Threads