<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>
<META content="MSHTML 6.00.2800.1522" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff size=2>Thanks
Guys,</FONT></SPAN></DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff size=2>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...</FONT></SPAN></DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff size=2>On a
side note ;-) the actual loop was more like:</FONT></SPAN></DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff
size=2>insertString := '';</FONT></SPAN></DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff
size=2>someDataset.First;</FONT></SPAN></DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff size=2>while
not someDataset.Eof do</FONT></SPAN></DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff
size=2>begin</FONT></SPAN></DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff
size=2> insertString := insertString +
Trim(someDataset.FieldByName('some_field').AsString);</FONT></SPAN></DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff
size=2> someDataset.Next;</FONT></SPAN></DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff
size=2>end;</FONT></SPAN></DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff size=2>A
'for' loop was just more concise. And range checking etc was turned on.
But we are not ungrateful for your efforts anyway.</FONT></SPAN></DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff size=2>Thanks
again,</FONT></SPAN></DIV>
<DIV><SPAN class=690331600-04112005><FONT face=Arial color=#0000ff
size=2>Samuel</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B>
delphi-bounces@ns3.123.co.nz [mailto:delphi-bounces@ns3.123.co.nz] <B>On
Behalf Of </B>Phil Middlemiss<BR><B>Sent:</B> Friday, November 04 2005 12:44
p.m.<BR><B>To:</B> NZ Borland Developers Group - Delphi
List<BR><B>Subject:</B> Re: [DUG] String Concatenation<BR><BR></FONT></DIV>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.<BR><BR>Phil.<BR><BR>Allan, Samuel wrote:
<BLOCKQUOTE
cite=mid9EA1E9775D329F4CB45B259FCA43F79F062D9798@its-xchg3.massey.ac.nz
type="cite">
<META content="MSHTML 6.00.2800.1522" name=GENERATOR>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=254273822-03112005>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:</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005>insertString, finalString:
string;</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005>for i := 0 to maxDataIndex do</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005> insertString := insertString +
dataItem[i];</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005>finalString := CONSTANT_A + insertString +
CONSTANT_B + insertString + CONSTANT_C;</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005>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.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=254273822-03112005>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=254273822-03112005>We
have also tried several variations on the above code:</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005>Using Copy() to create two additional strings, one
for each insert. Same result for finalString, both additional insert strings
are fine.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005>Putting placeholder tokens in the finalString, then
running StringReplace(). Same
result.</SPAN></FONT></DIV></SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=254273822-03112005>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.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005></SPAN></FONT><FONT face=Arial color=#0000ff
size=2><SPAN class=254273822-03112005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005>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.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005></SPAN></FONT><FONT face=Arial color=#0000ff
size=2><SPAN class=254273822-03112005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=254273822-03112005>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.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=254273822-03112005></SPAN></FONT> </DIV><PRE wrap=""><HR width="90%" SIZE=4>
_______________________________________________
Delphi mailing list
<A class=moz-txt-link-abbreviated href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</A>
<A class=moz-txt-link-freetext href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</A>
</PRE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>