[comp.lang.pascal] Printing from Turbo Pascal

mlw@pyr.gatech.EDU (Michael Williams) (02/28/90)

I am having difficulty printing a large file from Turbo Pascal 4.0.
It seems that the CPU overwhelms the printer's buffer and causes an I/O
error.  I have written some code to detect if the printer is OK, but it
doesn't work reliably.  (It does work most of the time).

   regs.ah := 2;
   regs.dx := 0;
   intr(23,regs);
   if regs.ah = 144 then printer_ok := true;

I also thought about exec'ing the DOS print command to attempt to print in 
the so-called "background".  However, that involves calling a TSR from a 
program, which is probably not a good idea.

Any suggestions???
-- 
Michael Williams
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp: ...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-ngp}!gatech!gitpyr!mlw
ARPA: mlw@pyr.gatech.edu

kemp@cs.umn.edu (Stuart R. Kemp) (03/01/90)

In article <9909@pyr.gatech.EDU> mlw@pyr.gatech.edu.gatech.edu (Michael Williams) writes:
>I also thought about exec'ing the DOS print command to attempt to print in 
>the so-called "background".  However, that involves calling a TSR from a 
>program, which is probably not a good idea.
>
>Any suggestions???

Instead of invoking DOS print from within the program, why not
invoke it *before* you start the program, and then just submit the
file to be printed? This can be done via an interrupt call.

-Stuart Kemp

rb@ac.dal.ca (03/01/90)

In article <9909@pyr.gatech.EDU>, mlw@pyr.gatech.EDU (Michael Williams) writes:
>...
> I also thought about exec'ing the DOS print command to attempt to print in 
> the so-called "background".  However, that involves calling a TSR from a 
> program, which is probably not a good idea.
> 
> Any suggestions???

It is a good idea to always put 'PRINT /d:lpt1' in your autoexec.bat. Then
it will always be loaded, and there will be no problem EXECing it from a TP
program. If it is not loaded already, it will load itself below the calling
program, and then you will have problems.
-------------------------------------------------------------------------------
Rick Ballard                         Bitnet : RB@AC.DAL.CA 
Medical Information Services
Dalhousie University
Halifax, Nova Scotia

ts@uwasa.fi (Timo Salmi LASK) (03/01/90)

In article <9909@pyr.gatech.EDU> mlw@pyr.gatech.edu.gatech.edu (Michael Williams) writes:
>I am having difficulty printing a large file from Turbo Pascal 4.0.
>It seems that the CPU overwhelms the printer's buffer and causes an I/O
>error.  I have written some code to detect if the printer is OK, but it
>doesn't work reliably.  (It does work most of the time).

I cannot guarantee that it works any better, but you could try
PRTONLFN (get the online status of a printer) in TSUNTC.TPU in
TSPAS18.ARC that was announced very recently in this newsgroup for
anonymous ftp from chyde.uwasa.fi directory /pc/ts. 

...................................................................
Prof. Timo Salmi        (Moderating at anon. ftp site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun