Board index » delphi » close(textfile) problem --- HELP please!

close(textfile) problem --- HELP please!

I have been using the following code to print for years:

 begin
 assign (TXT, 'prn');
 writeln(txt, mystring);
 { loop through the data files, writing many more writeln statements for
each record......}
 close(txt);
 end;

Typically, a whole bunch of pages gets generated.  The printer starts
printing, and when the close(txt) message occurs, the program returns to the
Main Menu while the printer keeps on going.

One user now tells me that the printer STOPS when the program returns to the
Main Menu.  This does not happen if I assign(txt, filename).  It sounds to
me as though the Windows 95 spooler somehow detects that close(txt)
statement and stops the printing then.  Is this possible?  Any suggestions
as to dealing with the problem?

If this is not the best place to post this, please let me know.

--
Jerry Blumenthal
note new email address, please
jblum...@stny.lrun.com

 

Re:close(textfile) problem --- HELP please!


Quote
Jerry Blumenthal wrote in message ...
>One user now tells me that the printer STOPS when the program
returns to the
>Main Menu.  This does not happen if I assign(txt, filename).  It
sounds to
>me as though the Windows 95 spooler somehow detects that close(txt)
>statement and stops the printing then.  Is this possible?  Any
suggestions
>as to dealing with the problem?

On one of my printers, I have had a similar problem, and I needed to
actually send the code to the printer to tell it that a page was
done (the EOF character, if I remember right), otherwise it doesn't
finish printing the last page, or most of the time doesn't print it
until after something else has been sent to the print queue.

--
jimsoft at geocities d com
http://www.horningabout.com/jimb

Re:close(textfile) problem --- HELP please!


Quote
Jerry Blumenthal wrote:

> I have been using the following code to print for years:

>  begin
>  assign (TXT, 'prn');

1) try 'LPT1' instead of 'PRN'. PRN is a logical device, while LPT1
is a physical device.
Quote
>  writeln(txt, mystring);

2) write(txt,^L); formfeed will force the spooler to send a "new page".
or
3) write(txt,^Z); EOF marker, MAYBE helpful ????

Quote
>  close(txt);
>  end;

You should try to use the PRINTER unit, it opens the file and
sends a proper IOCTL to the driver to run in "binary" mode.

Some hints may be found in the article "LPT2 printing" and in
some of the 1QA articles, found on the FAQ page of the TP-links:
http://start.at/tp-links
:-)
--
Franz Glaser, Glasau 3, A-4191 Vorderweissenbach Austria +43-7219-7035-0
Muehlviertler Elektronik Glaser.  Industrial control and instrumentation
http://members.eunet.at/meg-glaser/           mailto:meg-gla...@eunet.at
http://www.geocities.com/~franzglaser/ http://members.xoom.com/f_glaser/

Re:close(textfile) problem --- HELP please!


Quote
> On one of my printers, I have had a similar problem, and I needed to
> actually send the code to the printer to tell it that a page was
> done (the EOF character, if I remember right), otherwise it doesn't
> finish printing the last page, or most of the time doesn't print it
> until after something else has been sent to the print queue.

In my user's case, however, it is not that a page is left in the buffer.
The printer has printed, say, 4 of the 15 or so pages it has to print, and
when the program stops cycling through and executes close(textfile), the
last 11 pages are simply not sent to the printer.

Jerry

Re:close(textfile) problem --- HELP please!


Ing. Franz Glaser <meg-gla...@eunet.at> wrote in message
news:37275B2B.60C4D911@eunet.at...

Quote
> Jerry Blumenthal wrote:

> > I have been using the following code to print for years:

> >  begin
> >  assign (TXT, 'prn');
> 1) try 'LPT1' instead of 'PRN'. PRN is a logical device, while LPT1
> is a physical device.
> >  writeln(txt, mystring);
> 2) write(txt,^L); formfeed will force the spooler to send a "new page".
> or
> 3) write(txt,^Z); EOF marker, MAYBE helpful ????
> >  close(txt);
> >  end;

> You should try to use the PRINTER unit, it opens the file and
> sends a proper IOCTL to the driver to run in "binary" mode.

> Some hints may be found in the article "LPT2 printing" and in
> some of the 1QA articles, found on the FAQ page of the TP-links:
> http://start.at/tp-links

I will look at those links.  However, the problem I have found with using
the PRINTER unit is that I cannot then get the font as I need it.  All
printers have a Courier 10CPI font because the US govt requires it for their
forms.  Ordinarily this is font #0 in most printers.  I can NOT get a
Courier 10cpi SIX LINES PER INCH  font to print when I use the printer unit.
Maybe those links will tell me how.....

Jerry Blumenthal

Re:close(textfile) problem --- HELP please!


On Wed, 28 Apr 1999 21:02:03 +0200, "Ing. Franz Glaser"

Quote
<meg-gla...@eunet.at> wrote:
>3) write(txt,^Z); EOF marker, MAYBE helpful ????
>>  close(txt);

I wouldn't recommend sending a ^Z to the printer -- might seriously
confuse it.  Besides, a printer wouldn't know what to do with an End
Of File mark, even if you're using open() and close() instead of just
writeln (LST,your_data_goes_here).

What might help is the following procedure (assuming, of course, that
you're printing to a network printer). Use this after all the lines of
text have been printed, but _before_ you use close().

Procedure CloseNetWorkPrintJob;

var
  regs : registers;

begin

  regs.ax := $5D09;
  intr ($21,regs);

end;

Regards,
Jim Wilson
(Cheap spam protection in place: remove the 'SpamThis'
from my email ID to reply to me personally)

Re:close(textfile) problem --- HELP please!


In article <FALV2.7062$8m5.11...@newsr1.twcny.rr.com>,

Quote
Jerry Blumenthal <jerb...@stny.lrun.com> wrote:

>I will look at those links.  However, the problem I have found with using
>the PRINTER unit is that I cannot then get the font as I need it.  All
>printers have a Courier 10CPI font because the US govt requires it for their
>forms.  Ordinarily this is font #0 in most printers.  I can NOT get a
>Courier 10cpi SIX LINES PER INCH  font to print when I use the printer unit.
>Maybe those links will tell me how.....

What nonsense is that? The Printer unit knows nothing about fonts etc.
It just sends the data to the printer. If you need to change the fonts
then send the proper ESC sequences to the printer, for example on HP it
is something like #27'(s0p10h12V'

Osmo

Re:close(textfile) problem --- HELP please!


Quote
Osmo Ronkanen <ronka...@cc.helsinki.fi> wrote in message

news:7ga00g$mr@kruuna.Helsinki.FI...

Quote
> In article <FALV2.7062$8m5.11...@newsr1.twcny.rr.com>,
> Jerry Blumenthal <jerb...@stny.lrun.com> wrote:

> >I will look at those links.  However, the problem I have found with using
> >the PRINTER unit is that I cannot then get the font as I need it.  All
> >printers have a Courier 10CPI font because the US govt requires it for
their
> >forms.  Ordinarily this is font #0 in most printers.  I can NOT get a
> >Courier 10cpi SIX LINES PER INCH  font to print when I use the printer
unit.
> >Maybe those links will tell me how.....

> What nonsense is that? The Printer unit knows nothing about fonts etc.
> It just sends the data to the printer. If you need to change the fonts
> then send the proper ESC sequences to the printer, for example on HP it
> is something like #27'(s0p10h12V'

> Osmo

It may be nonsense (= my ignorance), or something else.  When I use the
printer unit and ASSIGNPRN, I get a different result than if I just use
SYSTEM.ASSIGN to open a textfile.  Generally, I have always used
system.assign (or just assign in the old days of TP 1.0), and it worked.
Nowadays, that still works most of the time: the output goes to the printer
with a series of WriteLn(txtfile, mystring) statements, and the Windows
spooler handles it without a problem, and the font is fine because Courier
with 6lpi and 10cpi is the default on all printers.  However, with some
setups, there are two problems:
  1. Nothing prints.  (probably because it is a Windows only printer, and
the DOS output is not accepted.
  2. When the CloseFile command is issued, Windodw's spooler flushes the
output it has in its buffers to the toilet.

So, I am looking for a way to use writeln commands with assignprn AND get
the font I need.  Will that exact escaped sequence work?  (I can easily send
that or something like it to the printer.)

Jerry Blumenthal

Re:close(textfile) problem --- HELP please!


Quote
Jerry Blumenthal wrote in message ...
>...  However, with some
>setups, there are two problems:
>  1. Nothing prints.  (probably because it is a Windows only
printer, and
>the DOS output is not accepted.
>...

Maybe you should be looking at Windows for a solution to this
problem, not at your program. For example, if you are running
Windows 95 and printing over a LAN you will get no printout from
DOS programs unless you tell Windows to capture the LPTx output:
click on start|settings|printers, right-click the printer icon,
select Properties. On the Details tab there's a Capture Printer
Port button, which allows you to associate LPT1..LPT9 with the
path of a printer. Maybe your users have to do some similar
setting up to allow DOS programs to print.

FP

Other Threads