I believe, there is nothing to do with string concatenation, but something is wrong when calling
>cString = cString + this.myproc(oObject)
for oObject.Name="one.three.two" in versions 6, 7 and 8.
The strange thing is that if you slightly modify the code, then everything seems mimic the VFP5 behavior:
cString1 = this.myproc(oObject)
cString = cString + cString1
Best Wishes
> Hi to all,
>
> The sample code bellow shows that a string can become shorter after
> concatenation. What happens is that the cString bit in cString = cString + cSomething
> vanishes.
>
> So, if
> cString = "TEST" and cSomething = " ANOTHER"
> After
> cString = cString + cSomething
> cString becomes:
> " ANOTHER"
>
> Which is obviously incorrect...
>
> Regrettably it is not all that simple. We needed the following program
> to reproduce this. We do know a simple workaround (Dutch ->
> 'omlossing'), but that, of course, is not the point. In Visual FoxPro
> 5.0a this code runs without any problems.
>
> I would like to know if this is a known bug, or if any of you
> encountered simular problems.
>
> Thanks,
> Benno.
>
>
>
> * SAMPLE CODE
>
> LOCAL oObjectTree
>
> oObjectTree = CREATEOBJECT("Custom")
> WITH oObjectTree
> .AddObject("One", "Custom")
> WITH .One
> .AddObject("One", "Custom")
> .AddObject("Two", "Custom")
> WITH .Two
> .AddObject("One", "Custom")
> .AddObject("Two", "Custom")
> WITH .Two
> .AddObject("One", "Custom")
> ENDWITH
> ENDWITH
> .AddObject("Three", "Custom")
> WITH .Three
> .AddObject("One", "Custom")
> .AddObject("Two", "Custom")
> WITH .Two
> .AddObject("One", "Custom")
> ENDWITH
> ENDWITH
> ENDWITH
> ENDWITH
>
> WITH CREATEOBJECT("executer")
> .myproc(oObjectTree)
> ENDWITH
>
> DEFINE CLASS executer AS Custom
> PROCEDURE myproc
> LPARAMETERS oParentObject
> LOCAL cString, nLen1, nLen2, oObject
>
> cString = ""
> FOR EACH oObject IN oParentObject.Objects
> cString = cString + "+"
> IF oObject.ControlCount > 0
> nLen1 = LEN(cString)
> cString = cString + this.myproc(oObject)
> nLen2 = LEN(cString)
> IF nLen2 < nLen1
> ? "The string became shorter after concatenation..."
> ENDIF
> ELSE
> cString = REPLICATE("-", 33)
> ENDIF
> ENDFOR
>
> RETURN cString
> ENDPROC
> ENDDEFINE
>