Board index » delphi » Printing Text Files

Printing Text Files

Hi.

I have a text file called (located) c:\text.out
What is/Is there a command for sending the textfile to the printer.
Hopefully its something simple like   print(text.out)    :)

--
Jimb...@Hotmail.com
-
it wasn't easy, but nothing never is, no.  -BLUR

Damons rule, Hill and Albarn, Jordan and BLUR

 

Re:Printing Text Files


Jimbahb schrieb:

Quote
> I have a text file called (located) c:\text.out
> What is/Is there a command for sending the textfile to the printer.
> Hopefully its something simple like   print(text.out)    :)

- Include "uses printer" in the head of your program.
- Read in each single line of c:\text.out
- then do a "writeln(lst, LineYouReadIn)" for each line

Re:Printing Text Files


First, you have to uses the 'print' unit, so add uses printer; to the
program, now it is very simple (unless I don't understand, I've never
used the printer before)  to print something, do this

Write (Lst, variablename,'Text you want to print');

The 'Lst' is a variable declared by the printer unit, and is associated
with LPT1, your printer port.  Try that, and tell me how it went :)

Jay Knight
Rytsar...@iname.com
http://jhknight.nexus.olemiss.edu
--------------------------------

Quote
Jimbahb wrote:
> Hi.

> I have a text file called (located) c:\text.out
> What is/Is there a command for sending the textfile to the printer.
> Hopefully its something simple like   print(text.out)    :)

> --
> Jimb...@Hotmail.com
> -
> it wasn't easy, but nothing never is, no.  -BLUR

> Damons rule, Hill and Albarn, Jordan and BLUR

Re:Printing Text Files


Quote
> I have a text file called (located) c:\text.out
> What is/Is there a command for sending the textfile to the printer.
> Hopefully its something simple like   print(text.out)    :)

uses Printer;

var TxtFile : text;
     Buffer : string;

begin
        Assign(TxtFile,'c:\text.out');
            {$I-} Reset(TxtFile); {$I+}

        if IOResult = 0 then
           begin
                while not eof(TxtFile) do
                        begin
                           ReadLn(TxtFile,Buffer);
                           WriteLn(lst,Buffer);
                        end;

                        close(TxtFile);
               end;
 end.

Regards Mike Heydon

Re:Printing Text Files


Quote
Jimbahb wrote:
> Hi.

> I have a text file called (located) c:\text.out
> What is/Is there a command for sending the textfile to the printer.
> Hopefully its something simple like   print(text.out)    :)

hmm... I *THINK* it'll be something like (never really used the printer
myself)

uses
  printer;

var
  myfile : text;
   tempstr : String;

begin
  Assign(myfile,'text.out');
  Reset(myfile);
   repeat
      Readln(myfile, tempstr);
      writeln(lst,tempstr);
    until (eof(myfile));
   Close(myfile);
end.

Telemachos

Re:Printing Text Files


   I know this is the c.l.p.b. NG, but if that's all you're needing to
do, why write a Pascal program to do it?  There are DOS and Windows
commands and utilities (PRINT, Copy, NotePad, word processors, etc.)
which will to the task quite well.
   Nevertheless, you've been given several programming answers (none of
them "command", btw) which should be useful.
Quote
> I have a text file called (located) c:\text.out
> What is/Is there a command for sending the textfile to the printer.
> Hopefully its something simple like   print(text.out)    :)

Re:Printing Text Files


I never understood the purpose of the "printer" unit.

What I usually do is,

  program myprog;
  var
    f: text;
  begin
    assign(f,'prn:');
    rewrite(f);
    writeln(f,'Hello world!');
    close(f);
  end.

In other words, it takes just three lines (assign, rewrite, and close)
to use my own file for the printer, instead of using "lst" as provided
by the printer unit.  Perhaps these three lines are all that is in the
printer unit?

In fact, more often, I don't even do that.  I just do this:

  program myprog;
  begin
    writeln('Hello world!');
  end.

And then, at the DOS prompt, I write,

  myprog > prn:

This gives me flexibility, for example I can type,

  myprog > results.txt

and then later, if I want,

  copy results.txt prn

I hope this helps.

     - Rich

Re:Printing Text Files


In article <364C5078.5...@best.com>, Rich Pasco  <pa...@best.com> wrote:

Quote
>I never understood the purpose of the "printer" unit.

>What I usually do is,

>  program myprog;
>  var
>    f: text;
>  begin
>    assign(f,'prn:');
>    rewrite(f);
>    writeln(f,'Hello world!');
>    close(f);
>  end.

>In other words, it takes just three lines (assign, rewrite, and close)
>to use my own file for the printer, instead of using "lst" as provided
>by the printer unit.  Perhaps these three lines are all that is in the
>printer unit?

Almost. There is also code that puts the port to binary mode so that one
can print graphics.

Osmo

Re:Printing Text Files


Mike Copeland schrieb:

Quote
>    I know this is the c.l.p.b. NG, but if that's all you're needing to
> do, why write a Pascal program to do it?  There are DOS and Windows
> commands and utilities (PRINT, Copy, NotePad, word processors, etc.)
> which will to the task quite well.
>    Nevertheless, you've been given several programming answers (none of
> them "command", btw) which should be useful.

Sure there are word processors - which are mostly in need of improvements.
Maybe the author of the original post simply wants to write an editor or
word processor himself.

Re:Printing Text Files


Quote
> >    I know this is the c.l.p.b. NG, but if that's all you're needing to
> > do, why write a Pascal program to do it?  There are DOS and Windows
> > commands and utilities (PRINT, Copy, NotePad, word processors, etc.)
> > which will to the task quite well.
> >    Nevertheless, you've been given several programming answers (none of
> > them "command", btw) which should be useful.

> Sure there are word processors - which are mostly in need of improvements.
> Maybe the author of the original post simply wants to write an editor or
> word processor himself.

   That's pretty "generous", IMO: he asked for a "pascal (sic) command
for printing text files", leading me to believe he's a Pascal newbie
who's probably also a student trying to get help on a school assignment.
I could be wrong, but his grammar, style, and phrasing indicated little
else - had he a real application in mind, wouldn't he have indicated
something of it?

Re:Printing Text Files


Quote
Rich Pasco wrote:
> I never understood the purpose of the "printer" unit.

.
.

Quote
> Perhaps these three lines are all that is in the
> printer unit?

Pretty much.  There are a few lines of basm to put the printer port into
binary mode

Re:Printing Text Files


In article <364CE3E1.84BA9...@premier1.net>,
Paul West  <pa...@premier1.net> wrote:

Quote
>Rich Pasco wrote:

>> I never understood the purpose of the "printer" unit.
>.
>.

>> Perhaps these three lines are all that is in the
>> printer unit?

>Pretty much.  There are a few lines of basm to put the printer port into
>binary mode

Actually they are in inline code.

Osmo

Re:Printing Text Files


On Fri, 13 Nov 1998 07:59:05 -0700, mrc...@primenet.com (Mike Copeland)
wrote:

Quote
>   I know this is the c.l.p.b. NG, but if that's all you're needing to
>do, why write a Pascal program to do it?  There are DOS and Windows
>commands and utilities (PRINT, Copy, NotePad, word processors, etc.)
>which will to the task quite well.

Maybe this is simply one facet of a larger program?

Maybe he just wants to learn how to print for future programming tasks?
God knows that I have no use for the door game I wrote when I was
learning Pascal that gets a random number, and gives the user 6 guesses.
But it taught me about random numbers, variables, sending output to the
user, retreiving user input, for/while loops, if..then..else statements,
and on and on.

Has your mentality swerved so much that you can't accept that a newbie
might not know as much about Pascal as you do?

Keep in mind that there was a time when you, too were still learning.

- Blackdeath - s_honsber...@13usa.net
-- Web: http://sprk.com/blackdeath
--- ICQ UIN # 3484915
---- Remove 'thir{*word*249}' to reply

Re:Printing Text Files


Mike Copeland schrieb:

Quote
>    That's pretty "generous", IMO: he asked for a "pascal (sic) command
> for printing text files", leading me to believe he's a Pascal newbie
> who's probably also a student trying to get help on a school assignment.
> I could be wrong, but his grammar, style, and phrasing indicated little
> else - had he a real application in mind, wouldn't he have indicated
> something of it?

There are not only English speaking people posting here. The "childish grammar"
could also be due to the fact that the author is not a native English speaker.

Other Threads