You've just stumbled across one of the many reasons why not to use "with"...
 
 
-Andreas
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Paul McKenzie
Sent: Wednesday, 28 August 2002 11:17
To: Multiple recipients of list delphi
Subject: Re: [DUG]: weird behavour with Format

Yes - you are right me being stupid - TestString (Filter) is a property of TDataSet - I checked TIBQuery and couldn't see it.
On reflection pretty damn obvious - filtering etc...
 
 
 - sigh - I suppose missing the obvious is to be expected with sick kids waking everyone up  at all hours :-o (big yawn)
 
Regards
Paul McKenzie
Analyst Programmer
SMSS Ltd.
----- Original Message -----
Sent: Wednesday, August 28, 2002 11:00 AM
Subject: Re: [DUG]: weird behavour with Format

A guess..  TestString is a property or method of qryMyQuery and your with is accessing this instead of your variable.
 
Rob
 
Software engineer
Wild Software Ltd
Ph 03 338-1407
----- Original Message -----
Sent: Wednesday, August 28, 2002 10:18 AM
Subject: [DUG]: weird behavour with Format

I have struck some weird behaviour:
 
We use "Format" to format SQL Strings - this usually works (has so far, used three times) ...
The following code will not work if contained inside the "with" statement - and it is only setting a local variable !!!
I can't see or understand why ?
I have the same constructs in other parts of my code - all working fine
 - I have checked the TIBQueries, they are identical apart from SQLString, SQLParameters, and Name.
 - I even copied 1 across and used it - same result!
This should not affect the assigning of a local variable ...
 
I am avoiding the "with" (it all works) but I would love to know why and if anyone else has come across this ?
 
procedure MyProcedure ...
const
  csString = 'This is an example string ' +
             'this %s string ' +
             'is a test';
var
  TestString: String;
  ResultString: String;
begin
  TestString := 'Blah Blah Blah;
  with qryMyQuery do
  begin
    ResultString := Format(csString, [TestString]); // Inserts ''
  end;
  ResultString := Format(csString, [TestString]);   // Inserts 'Blah Blah Blah'
end;
 
 
Regards
Paul McKenzie
Analyst Programmer
SMSS Ltd.

Reply via email to