Page 1 of 1

Wrong printer picked up

Posted: Fri Jul 28, 2006 12:17 am
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

Re: Wrong printer picked up - SOLVED

Posted: Sun Jan 14, 2007 2:37 am
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

Posted: Sun Jan 14, 2007 7:27 am
by Antonio Linares
Davide,

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

PRINT oPrn NAME cName TO "fax"

Posted: Sun Jan 14, 2007 10:31 am
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

Posted: Sun Jan 14, 2007 5:17 pm
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

Posted: Sun Jan 14, 2007 5:55 pm
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

Posted: Sun Jan 14, 2007 7:39 pm
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

Posted: Mon Jan 15, 2007 11:47 am
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.

Posted: Mon Jan 15, 2007 5:52 pm
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

Posted: Mon Jan 15, 2007 6:33 pm
by Antonio Linares
Davide,

Very good, thanks! :-)

Posted: Mon Jan 15, 2007 7:14 pm
by James Bott
Davide,

I like your second solution. Nice.

James