Board index » delphi » NET PRINT from TP5

NET PRINT from TP5

I have a Turbo Pascal program running on a PC which has recently been
given an Ethernet card and connected to a Network.  The PC has NFS software
installed.  I have LPT2: defined as a laser printed which is on the Network.

At the DOS level the command   NET PRINT filename LPT2: works fine.
If I provide the statements
        SwapVectors;
        Exec('C:\NFS\NET.EXE','PRINT fileame LPT2:');
        SwapVectors
in a trivial TP5 program (in which I have reduced to size of the heap somewhat)
it still works fine.  When I put the same code in my real program (.EXE file
of size 133K) nothing prints, even when I reduce the heap to half its maximum
size.

And suggestions would be appreciated.

                        Bob Hale  (r...@deakin.edu.au)

 

Re:NET PRINT from TP5


Dear Bob,

I have used the following basic concept to print from a pascal program to a
network printer in several network systems and it has worked well:

procedure PrintFile (Fname, Port : string);

var inf, outf : text;
    s         : string;

begin
  assign (inf, Fname);
  reset (inf);
  assign (outf, port);  { e.g. 'LPT2' }
  rewrite (outf);
  while not eof (inf) do
  begin
    readln (inf, s);  writeln (outf, s);
  end;
  close (inf);
  close (outf);
end;

This is only the basic concept and it should be completed with IO error checks
and printer status checks.  Also it is limited to 255 char lines, but that can
be changed.

Good luck  -Ike.

Other Threads