<!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>
<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>&nbsp;</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>&nbsp;</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>&nbsp;&nbsp; insertString := insertString + 
dataItem[i];</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN 
class=254273822-03112005></SPAN></FONT>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</DIV></BODY></HTML>