Print problem in text mode

Issues and Discussions related to Harbour

Moderator: Rathinagiri

User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Print problem in text mode

Post by esgici »

martingz wrote:Esgici try chage this

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WOW\LPT_timeout

default 15 change to 1

works fine in XP
Thank Martin :)

Viva HMG :D
Viva INTERNATIONAL HMG :D
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Print problem in text mode

Post by esgici »

Hi all

With a hope about someone may be encountered already this problem ( and hopefully solved ),

I want repeat explanation :

- There is an application that compiled by Clpr S'87 and run perfect.
- Source files re-built by HB32 ( with some rectifications )
- Seems everything is OK except SOME print process : print-out come only after application terminated ( QUIT ).

Definitely something different between S'87 and HB32 builts :?

All kind of help will be appreciated :arrow:

By the way,
Jayadev wrote:I can help you with a generic text converter.
I'm still waiting that text converter :?

Viva HMG :D
Viva INTERNATIONAL HMG :D
jayadevu
Posts: 238
Joined: Tue May 19, 2009 7:10 am

Re: Print problem in text mode

Post by jayadevu »

Hi,

The generic converter is of use only if you want to print your existing .txt or .prn file to any printer like usb based etc. It does not wait for you to quit the program to print. Actually what is happening is your print spooler is waiting for a job to finish spooling. When you quit the program, the job finishes spooling and it fires the job. I had similar problems which were overcome by the use of winprintraw commands.

Please show me a small code snippet of your printing routine. a KISS example :D will be highly appreciated.

Please download the following utility from https://dl.dropboxusercontent.com/u/593 ... nagerG.Exe" onclick="window.open(this.href);return false;" onclick="window.open(this.href);return false; and use it to print any .txt or .prn file to any of the printers available in your computer or network. My converter allows you to convert your general .txt file into one that the usb printers understand.

HTH,

Warm regards,

Jayadev
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Print problem in text mode

Post by andyglezl »

Revisando mis programas de aquellos años cuando S'87, yo tenia ese problema cuando imprimia en red.

Y se solucionó con lo siguiente: SET PRINTER TO LPT1.
Porque ? , no lo se pero funcionó.
--------------------------------------------------------------------------------------------------
Reviewing my programs S'87 those years when I had that problem when printed in red.

And was solved with the following: SET PRINTER TO LPT1.
Why? , I do not know but it worked.

Code: Select all

        SET DEVICE TO PRINTER
        SET PRINTER TO listado.txt    
        *-*-*-*-*-*-*-*-*-*-*
        SET PRINTER TO LPT1.   
        *-*-*-*-*-*-*-*-*-*-*
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Print problem in text mode

Post by esgici »

Hi Jayadev
jayadevu wrote: The generic converter is of use only if you want to print your existing .txt or .prn file to any printer like usb based etc. It does not wait for you to quit the program to print. Actually what is happening is your print spooler is waiting for a job to finish spooling. When you quit the program, the job finishes spooling and it fires the job. I had similar problems which were overcome by the use of winprintraw commands.
a job to finish spooling

This is interesting , and problem may be this. :?

Would you please teach me about where I can find info about that subject and how can I overcome this obstacle ?

I other hand that application never use "write report to a file, and and than send this file to printer" method.
Please show me a small code snippet of your printing routine. a KISS example :D
Well,

The most used code fragment for printing in the application is (summarized ):

Code: Select all

   
   STORE 0 TO pagenum, counter
   TLINE = 61
   title( "Selling Price List", 4 )
   GO TOP
   SET DEVICE TO PRINT
   DO WHILE .NOT. EOF() 
      DO REPHEAD  // Print head lines, increment and print page no etc
      @ TLINE + 6, 1 SAY "CODE     DESCRIPTION                        PRICE UNIT"
      @ TLINE + 7, 1 SAY ULINE
      STORE TLINE + 8 TO TLINE
      @ TLINE, 1 SAY STKCODE + " " + DESCR + " " + Str( SELL&T, 7, 2 ) + " " + unit
      TLINE = TLINE + 1
      SKIP
   ENDDO
   SET DEVICE TO SCREEN
And the second :

Code: Select all

   the_prn = "LPT" + alltrim(str(mprinter2))  // mprinter2 is printer port no ( 1/2 ) of user
   set printer to &the_prn
   store 0 to tline
   set device to print
   heading = "ACCOUNT PAYMENT"
   @ tline,1 say MCODE
   @ TLINE + 1,1 SAY MREF
   @ tline + 2,33 SAY "---------"
   @ tline + 3,23 SAY "T O T A L"
   @ tline + 3,33 say STR(msub,9,2)
   @ tline + 4,33 SAY "========="
   @ TLINE + 6,1 SAY MUSERNAME
   eject_paper()

   @ tline,1 say MCODE
   @ TLINE + 1,1 SAY MREF
   @ tline + 2,33 SAY "---------"
   @ tline + 3,23 SAY "T O T A L"
   @ tline + 3,33 say STR(msub,9,2)
   @ tline + 4,33 SAY "========="
   @ TLINE + 6,1 SAY MUSERNAME
   eject_paper()
   set_condoff()
   SEtpgln(66)
   the_prn = "LPT" + alltrim(str(mprinter1))
   set printer to &the_prn
   set device to screen
By the way, this isn't "my" program; I'm working to help to a friend.
Please download the following utility ... and use it to print any .txt or .prn file to any of the printers available in your computer or network.
Done; your utility truncates lines :(
My converter allows you to convert your general .txt file into one that the usb printers understand.
My curiosity about your converter is rising ;)

Anyway, TIA :D

@Andres : Thank to tip.

Viva HMG :D
Viva INTERNATIONAL HMG :D
jayadevu
Posts: 238
Joined: Tue May 19, 2009 7:10 am

Re: Print problem in text mode

Post by jayadevu »

Hi Esgici,

The simplest approach in this case would be:

Code: Select all

//1. Create the following functions in your main prg file
 function loadfile(cFname)
  set printer to (cFname)
  set device to printer
  set printer on
  setprc(0,0)
  //page_no() - optional function to print page no
return NIL

Function UnloadFile
  setprc(0,0)
  set device to screen
  set printer off
  set printer to
  pg_no := 0
return NIL

function reportfile(cFile)
   LOCAL t := 3,l := 0, b := MaxRow()-2, r := MaxCol()
   LOCAL save_win := win_save()
   local ADISPCOLORS := {;
                              { '~~R', 'W+/R'  } ,;
                              { '~~7', 'W/N'   } , ;
                              { '~~N', 'N/R'   } , ;
                              { '~~D', NIL     };
                  }
 // filebrowse is a function dowloaded from OASIS, very good function, does not display control characters and
 // file can be of any size)
   filebrowse(cFile,t,l,b,r,;
              "bg+/b","bg/b","bg+/b","gr+/bg",,aDispColors)
   win_rest(save_win)
return NIL

Function PrintFile(cFile)
#ifdef __XHARBOUR__
WinPrintRaw( cPrinter,cFile,cFile )
#else
WIN_PRINTFILERAW( cPrinter, cFile, cFile )
#endif
return NIL
1. Now replace all you set printer to ... commands in your program with loadfile(cFile), you can default the filename if you want in the loadfile function.
2. Replace all your set device to screen... commands in your program to unloadfile()
3. You can now use the function reportfile(cFile) to preview the report on screen.
4. You can use the function printfile(cFile) to print the file. This way all print part is handled at one place, you can later modify the printfile to print to USB/GDI only printer.

Alternatively, you can replace ONE SET OF "set printer to .. set device to screen" with the above functions loadfile and unloadfile, see its effect and then proceed to replace all the set commands progressively.


For the Generic Text Converter, please send me a email at ujayadev_@_gmail.com (remove the underscores).

HTH,

Warm regards,

Jayadev
Post Reply