Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Yuri Rubinov
  Where is Yuri Rubinov?
 Philadelphia
 Pennsylvania - United States
 Yuri Rubinov
 To: Benno Richters
  Where is Benno Richters?
 Delft
 Netherlands
 Benno Richters
 Tags
Subject: RE: String Manipulation Bug
Thread ID: 22351 Message ID: 22367 # Views: 2 # Ratings: 0
Version: Visual FoxPro 8 Category: General VFP Topics
Date: Wednesday, April 16, 2003 4:09:43 PM         
   


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
> 



COMPLETE THREAD

String Manipulation Bug Posted by Benno Richters @ 4/16/2003 11:58:50 AM
RE: String Manipulation Bug Posted by Yuri Rubinov @ 4/16/2003 4:09:43 PM
RE: String Manipulation Bug Posted by Benno Richters @ 4/16/2003 4:45:50 PM
RE: String Manipulation Bug Posted by Yuri Rubinov @ 4/16/2003 8:14:42 PM