Wrong printer picked up

Post Reply
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Wrong printer picked up

Post by Davide »

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
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Re: Wrong printer picked up - SOLVED

Post by Davide »

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()

Code: Select all

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

Code: Select all

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Post by Davide »

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
User avatar
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Post by Richard Chidiak »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

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
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Post by Davide »

Antonio, Richard, James,
Antonio Linares wrote:I am afraid that we may break existing applications if we change it in FWH
what about:

Code: Select all

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.
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Post by Davide »

even better:

Code: Select all

If ( nScan := Ascan(aPrn, {|v| Upper(xModel)==Upper(v) }) ) = 0
  nScan := Ascan(aPrn, {|v| Upper(xModel)$Upper(v) }) 
Endif
Hi,
Davide
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Davide,

Very good, thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Davide,

I like your second solution. Nice.

James
Post Reply