I've had some issues with printers before due to funny changes to
case. Try replacing
if trim(printer.printers[iLoop])=pn then
with
if sametext (trim(printer.printers[iLoop]), pn) then
and see if that resolves the problem.
At 03:59 AM 9/1/2006, Chris Moore wrote:
>Hello List,
>
>This function DOES work on my development machine (XP SP2) but DOES NOT work
>on the target PC (XP SP2).
>
>Function TestForPrinter(pn:string):Boolean;
>var
>r:Boolean;
>ni,iloop:integer;
>mess:string;
>begin
>r:=true;
>ni:=-1;
>for iloop:=0 to printer.printers.Count-1 do
> begin
> if trim(printer.printers[iLoop])=pn then
> begin
> ni:=iLoop;
> end;
> end;
>if ni<1 then // Oh No - No Printer
> begin
> r:=false;
> mess:='!! ERROR - printer '+pn+' not installed on this PC !!'+#10;
> mess:=mess+''+#10;
> mess:=mess+'Contact the Computer Department'+#10;
> showmessage(mess);
> end;
>TestForPrinter:=r;
>end;
>
>This snippet works on both PC's - (I thought the trim function might be
>getting in the way so I put logic in to test)
>
>procedure testy;
>var
>iloop:integer;
>pn,an:string;
>begin
>form1.CheckListBox1.Clear;
>pn:=form1.edt_find.Text; {tedit used to test for printers and duffstuff}
>for iloop:=0 to printer.printers.Count-1 do
> begin
> form1.CheckListBox1.Items.Add(printer.printers[iLoop]);
> if form1.CheckBox1.Checked then
> an:=trim(printer.printers[iLoop])
> else
> an:=printer.printers[iLoop];
> if an=pn then
> form1.CheckListBox1.Checked[iLoop]:=true;
> end;
>end;
>
>Why does one work and the other not? - I am confused++
>
>Chris Moore
>Computer Department
>
>Brother Industries (UK) Ltd
>
>
>
>
>_______________________________________________
>Delphi mailing list -> [email protected]
>http://www.elists.org/mailman/listinfo/delphi
Regards,
Sid Gudes
PIA Systems Corporation
[EMAIL PROTECTED]
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi