FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Wrong printer picked up
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Wrong printer picked up
Posted: Fri Jul 28, 2006 12:17 AM

I'm currently using FWH27, but it's a long time problem even with previous FW(H) versions.

If I have 2 printers with similar long names, for example:
HP Officejet 6200 series fax
HP Officejet 6200 series

PRINT oPrn NAME cName TO "HP Officejet 6200 series" - may pick up the fax one.
The FROM USER clause always works well.

I know that as a workaround you can rename the first one simply as HPFax, but I was wandering if this could be solved definitely.

Thank you,
Davide

Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Re: Wrong printer picked up - SOLVED
Posted: Sun Jan 14, 2007 02:37 AM
Davide wrote:If I have 2 printers with similar long names, for example:
HP Officejet 6200 series fax
HP Officejet 6200 series

PRINT oPrn NAME cName TO "HP Officejet 6200 series" - may pick up the fax one.


Solved: In Printer.prg - Function PrintBegin()
nScan := Ascan(aPrn, {|v| Upper(xModel)$Upper(v) })

should be changed as:
nScan := Ascan(aPrn, {|v| Upper(xModel)==Upper(v) })

Antonio, there was a particular reason for searching only part of the printer name in the array ?

Hi,
Davide
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Wrong printer picked up
Posted: Sun Jan 14, 2007 07:27 AM

Davide,

Yes, because that way you could use just part of a name, i.e.:

PRINT oPrn NAME cName TO "fax"

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Wrong printer picked up
Posted: Sun Jan 14, 2007 10:31 AM
Antonio Linares wrote:PRINT oPrn NAME cName TO "fax"

Uhm, that way if you have more than a printer containing the word "fax" you don't know which one will be picked up.

In addition, even using the TO <entire_printer_name> you may experiencing problems, like in the example I've posted above. More and more all-in-one printers nowadays are installing printer drivers named that way.

Regards,
Davide
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Wrong printer picked up
Posted: Sun Jan 14, 2007 05:17 PM

Antonio :(

This is not the correct windows behaviour.

I agree with DAVIDE, we should pick the "exact" printer.

I also have this problem of wrong printer selected, fax returned instead of the printer. In this case, i rename one of the printers...

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Wrong printer picked up
Posted: Sun Jan 14, 2007 05:55 PM

Davide, Richard,

We can easily modify it as Davide has suggested but I am afraid that we may break existing applications if we change it in FWH

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Wrong printer picked up
Posted: Sun Jan 14, 2007 07:39 PM

Antonio,

I would vote for fixing the problem even if it breaks some existing applications. You could put a warning in the What's New file. However, it is not me that developers might be upset with if existing apps are broken, so I understand why you would not want to do that.

May I offer a compromise. Add an lExactName var we can set to force it to use exact naming, and default it to false. That way no existing apps will be broken.

The alternative would be to set it to true. Existing apps that are affected would then have to change it to false but it would be a simple fix.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Wrong printer picked up
Posted: Mon Jan 15, 2007 11:47 AM
Antonio, Richard, James,
Antonio Linares wrote:I am afraid that we may break existing applications if we change it in FWH

what about:
aPrn:=ASORT(aPrn)
nScan := Ascan(aPrn, {|v| Upper(xModel)$Upper(v) })

This way the <exact_printer_name> should be selected because it's found before <exact_printer_name>+" fax", solving both needs.
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Wrong printer picked up
Posted: Mon Jan 15, 2007 05:52 PM
even better:
If ( nScan := Ascan(aPrn, {|v| Upper(xModel)==Upper(v) }) ) = 0
  nScan := Ascan(aPrn, {|v| Upper(xModel)$Upper(v) }) 
Endif

Hi,
Davide
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Wrong printer picked up
Posted: Mon Jan 15, 2007 06:33 PM

Davide,

Very good, thanks! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Wrong printer picked up
Posted: Mon Jan 15, 2007 07:14 PM

Davide,

I like your second solution. Nice.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion