Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Printing a File from a Program

1 view
Skip to first unread message

Robert Joseph Kaighn

unread,
Nov 30, 1994, 4:56:18 PM11/30/94
to
I'm trying to print a file from a TVision program that I wrote, and
I'm having some problems. I'm trying to use the DOS print command (I
thought that would be easiest) and it's not working. I wrote this
small program to test....

Program PrintaFile;
Uses DOS;

Begin
SwapVectors;
EXEC('PRINT.EXE','/d:lpt1 qfld.dat');
Writeln(DosError);
SwapVectors;
End.

qfld.dat is a small file in the current directory. When I run the
program, DosError returns 8. I even tried making an .exe file and
running it and it still returned 8 (out of memory). Any ideas?

If you have a better way to print a file, I'll take that too.

Thanks.
--
Rob Kaighn |
rj...@virginia.edu | I once had what it takes,
Civil Engineering | but I'm afraid it's all been taken.
Grad. Student |

Syed Reza

unread,
Dec 2, 1994, 11:15:31 AM12/2/94
to

>Program PrintaFile;
> Uses DOS;

Try this,

var

OneLine:string;
Printer:text;
Infile:text;

begin
Assign (Infile, 'qfld.dat');
Reset (Infile);
Assign (Printer, LPT1); {assumes you have the printer on LPT1}
Reset (Printer); {LPT1 may need to be in quotes, i am not sure}

repeat
readln (Infile, OneLine);
writeln (Printer, OneLine);
until eof (Infile);

Close (Infile);
Close (printer);
end;

If you have the printer manual look up the control characters. Use
writeln to send them to the printer and set things like unidirectional
printing, continuous feed, colors etc.

I hope this helps.
Syed Reza

0 new messages