Harbour progs and DosPrn

475 views
Skip to first unread message

Franz Rachbauer

unread,
Sep 13, 2019, 5:13:34 AM9/13/19
to Harbour Users
Hi there,
i've some old clipper progs where I capture output to LPT1: with DosPrn, this does well.
If I compile these progs with hb3.0 it's no more possible to capture output, it prints directly to LPT1:
Is there a solution to capture output to LPT1: in hb3.0 progs?
Thanks, Franz

Paola Bruccoleri

unread,
Sep 13, 2019, 7:38:55 AM9/13/19
to harbou...@googlegroups.com

Hi Franz
You could put in a bat this commands:

net use lpt1 /d
net use lpt1 \\srver\name_print /persistent:yes

I hope you solve it
byeee


De: "Franz Rachbauer" <off...@rachbauer.org>
Para: "Harbour Users" <harbou...@googlegroups.com>
Enviados: Viernes, 13 de Septiembre 2019 6:13:34
Asunto: [harbour-users] Harbour progs and DosPrn
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/6cabb20b-871e-4a7a-b658-c9573e507f0c%40googlegroups.com.

Franz Rachbauer

unread,
Sep 14, 2019, 6:12:30 AM9/14/19
to Harbour Users
Hi Paola,
I think this does not solve the problem, cause dos progs can't print to windows printers directly.
A dos printer needs an epson or ibm emulation or the dos output must be converted into windows output like dosprn does.
This does well with Clipper progs but with same progs compiled with hb3.0 it does not!
Regards, Franz

Paola Bruccoleri

unread,
Sep 14, 2019, 11:04:11 AM9/14/19
to harbou...@googlegroups.com
Hi Franz
Many years ago I use that to print from harbor console programs (hb3.2 and before hb30) without problems.
The same thing works for me in harbor as in clipper without changing anything.
I also use dosprinter for other listings.
The printer is an epson matrix printer and the pc have win7 pro (with win10 too)
Maybe I am not understanding your problem
byeeeee

PROCEDURE ImprimirVentas()
set device to print

ventas->(DbSeek (nVale1))
if ImpON()
   WHILE ventas->documento <= nVale2 .and. !ventas->(eof())
      // se imprime el cabezal de cada hoja
      EncabLis (@f,hojas)
      f:= f+3
      @F,25 say 'LISTADO DE VALES CANCELADOS EN '+If(cMon=='P','PESOS','DOLARES')
      F:= F+2
      @f,1 say replicate(chr(196),79)
      f++
      @f,3 say 'DOCUMENTO   CLIENTE                                       FECHA       SALDO'
      f++
      @f,1 say replicate(chr(196),79)
      f++

      WHILE  f<=66 .and. ventas->documento <= nVale2 .and. !ventas->(eof())
         if ventas->saldo < 1
            @f,3  say ventas->serie
            @f,4  say ventas->documento pict '999999999'
            @f,15 say ventas->nrocliente pict '999999'
            nCli:= ventas->nrocliente
            clientes->(DbSeek(nCli))
            cNomCli:= alltrim(substr(clientes->apellidos,1,16))+','+alltrim(substr(clientes->nombres,1,16))
            @f,22 say cNomCli
            @f,59 say ventas->fecha_emi
            @f,73 say ventas->saldo pict '9,99'
            f++
         endif
         ventas->(DbSkip())
      END
      hojas++
   END
   @f,1 say replicate(chr(196),79)
   eject
endif
set printer to
prcommit()
set device to screen
RETURN


//----------------------------------------------------------------------------
FUNCTION PRCOMMIT()
//----------------------------------------------------------------------------
set default to
SET PRINTER OFF
set printer to  
RETURN .t.


De: "Franz Rachbauer" <off...@rachbauer.org>
Para: "Harbour Users" <harbou...@googlegroups.com>
Enviados: Sábado, 14 de Septiembre 2019 7:12:30
Asunto: Re: [harbour-users] Harbour progs and DosPrn
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Franz Rachbauer

unread,
Sep 16, 2019, 3:52:59 AM9/16/19
to Harbour Users
Hi Paola,


Am Samstag, 14. September 2019 17:04:11 UTC+2 schrieb Paola Bruccoleri:
Hi Franz
Many years ago I use that to print from harbor console programs (hb3.2 and before hb30) without problems.
The same thing works for me in harbor as in clipper without changing anything.
I also use dosprinter for other listings.
The printer is an epson matrix printer and the pc have win7 pro (with win10 too)


and that's the problem: my printer is a Brother MFC-J5335 windows only printer which can't print output with Epson ESC sequences which I have in listing.
Franz

Jayadev U

unread,
Sep 16, 2019, 5:21:05 AM9/16/19
to harbou...@googlegroups.com

Hi,

 

You can use the following generic function to print directly.

 

https://www.dropbox.com/s/x6fg8x2ngmc6cuv/txt2gdih.prg?dl=0

 

Please modify it to suit your purpose.

 

HTH,

 

Warm regards,

 

Jayadev

--

--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Franz Rachbauer

unread,
Sep 19, 2019, 12:04:22 AM9/19/19
to Harbour Users
Hi Jayadev,
thank you for sharing code but I already have a function to convert ESC P code to windows output.
My question was: What is the diff between clipper and hb3.0 "set device to print", because I can capture LPT1 output with DosPrn when prog is compiled with clipper while same prog compiled with hb3.0 output is printed directly to LPT1 and not captured? How can I capture LPT1 output from hb3.0 progs with DosPrn?
Regards, Franz

W.

unread,
Sep 19, 2019, 6:48:36 AM9/19/19
to Harbour Users
Don't rely on DosPrn, program compiled with Harbour for Win is not a DOS program anymore.
You can use: SET PRINTER TO "\\server\port"
or if you want to use system spooler print to a file and later call
Win_PrintFileRaw( cWinPrinterName /* "HP LaserJet 5L" or whatever */, cFileName, "Description of the printjob"  )

Regards,
w.

W.

unread,
Sep 19, 2019, 6:59:25 AM9/19/19
to Harbour Users
ADD:
It's not obvious from your question, but you may emit your print codes in Epson Proprinter emulation - so you still need some conversion. In that case print to a file, after you finish, copy the file to the location which is monitored by DosPrn. AFAIR DosPrn has such functionality to print all files from a folder.

Pete

unread,
Sep 19, 2019, 8:48:42 AM9/19/19
to Harbour Users


On Thursday, 19 September 2019 07:04:22 UTC+3, Franz Rachbauer wrote:
thank you for sharing code but I already have a function to convert ESC P code to windows output.

then why you not print this output directly to your printer?
 
My question was: What is the diff between clipper and hb3.0 "set device to print", because I can capture LPT1 output with DosPrn when prog is compiled with clipper while same prog compiled with hb3.0 output is printed directly to LPT1 and not captured?

the (BIG) difference is that clipper executable is 16bit DOS program while hb3.0 executable is 32bit native Windows program. 
Both executable, however, know nothing about Lpt1 capturing;  they both send their output to OS for farther processing (printing). 
Dos prints directly to Lpt1, but windows does not! 
I guess, dosprint  is monitoring the LPT1  port on "Dos level", (through interrupt calls, perhaps?)  and captures data traffic going to it.
Windows do not allow such direct Lpt1 access, printouts are send to spooler and printing is controlled by printers drivers.
(So don't wonder about harour3.0 executable capturing; just think for a moment why printing through notepad for example, is not also captured by dosprint 
and you have the answer to your questions).

How can I capture LPT1 output from hb3.0 progs with DosPrn?
 
you cannot! obviously because dosprint cannot do it, so  you'd better forget it, unless you are ready to  
ask hb30 to create for you a dos executable (yes! you can do it, provided you have the proper tool-set) 
and then keep using dosprint. -- seriously though, it can't even be considered as an option. ;-)

two other things you can do: 
 
1. redirect LPT1 to a usb printer, as suggested.
2. rewrite application's printing routines, exploiting printing capabilities offered 
    by hbwin library (btw, you can also create pdfs using hbhpdf library and print them easily).

(well, the option (2.) is the most rational way to go, but requires some work! 
if you don't want to do it,  you can always hire someone to do it for you).

regards,
Pete 

Rajesh Mishra

unread,
Sep 19, 2019, 1:04:06 PM9/19/19
to Harbour Users
Harbour create temporary file when you select file name as prn or lptn and sent to spooler of default printer. Therefore dosprn does not capture .

Franz Rachbauer

unread,
Sep 23, 2019, 5:02:52 AM9/23/19
to Harbour Users
Hi W., Pete and Rajesh,
thank you for answers, now I understand why DosPrn can't capture print output from hb3.0!
My intention was to print to windows printers on 64bit windows from my old dos programs without changes in source code, but it looks like I have to do some work!
Thanks again, Franz

Franz Rachbauer

unread,
Sep 23, 2019, 6:16:03 AM9/23/19
to Harbour Users
My solution:
In my print routines I add fot spool output to file
set device to print
#ifdef __HARBOUR__
   set printer to c:\tmp\dosprn.tmp
#endif

In DosPrn I activate "Autoprint" and spool filename "c:\tmp\dosprn.tmp".
So DosPrn captures written file and not LPT1.

Regards, Franz
Reply all
Reply to author
Forward
0 new messages