[DUG] String Concatenation

Allan, Samuel S.A.Allan at massey.ac.nz
Fri Nov 4 13:33:09 NZDT 2005


Thanks Guys,
 
We were completely flummoxed. It was indeed the Inspect Dialog. When we
pumped out the string in another way we found it was fine. Well, apart
from the normal error that caused us to debug in the first place...
 
On a side note ;-) the actual loop was more like:
 
insertString := '';
someDataset.First;
while not someDataset.Eof do
begin
    insertString := insertString +
Trim(someDataset.FieldByName('some_field').AsString);
    someDataset.Next;
end;
 
A 'for' loop was just more concise. And range checking etc was turned
on. But we are not ungrateful for your efforts anyway.
 
Thanks again,
Samuel

-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz]
On Behalf Of Phil Middlemiss
Sent: Friday, November 04 2005 12:44 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] String Concatenation


The Inspect dialog does funny things when inspecting strings, even
though the contents are fine. If the actual output of the string is
giving you problems then try using an AnsiString.

Phil.

Allan, Samuel wrote: 

We have a weird problem where we are building a string up. It is quite a
large string, but not exceptionally large. About maybe 1000 characters.
The code to create the string approximates:
 
insertString, finalString: string;
 
for i := 0 to maxDataIndex do
   insertString := insertString + dataItem[i];
 
finalString := CONSTANT_A + insertString + CONSTANT_B + insertString +
CONSTANT_C;
 
Without throwing an overflow warning or any other warning, this code
results in a finalString where the first instance of insertString is
whole and complete. The second instance is interrupted half-way by what
looks like a random memory dump, and there is no CONSTANT_C afterwards.
insertString remains pristine and untouched.
 

We have also tried several variations on the above code:
 
Using Copy() to create two additional strings, one for each insert. Same
result for finalString, both additional insert strings are fine.
 
Putting placeholder tokens in the finalString, then running
StringReplace(). Same result.
 
We tried to isolate the code in a separate application. The separate
application works fine, as you would expect. So we think it may be
something to do not with the code itself, but with the structure of our
application. However, code like this is widely used within this
application and elsewhere works fine.
 
Our application implicitly compiles several packages into itself. The
code in question is in one of these packages. So compiling any change to
it requires compiling the package, then compiling the application.
 
We have searched the web, and found an exact match for this posted in
some newsgroup in 1998, but there were no responses. The match does not
mention packages however.
 


  _____  


_______________________________________________

Delphi mailing list

Delphi at ns3.123.co.nz

http://ns3.123.co.nz/mailman/listinfo/delphi

  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ns3.123.co.nz/pipermail/delphi/attachments/20051104/e3110100/attachment.html


More information about the Delphi mailing list