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: 22382 # Views: 15 # Ratings: 0
Version: Visual FoxPro 8 Category: General VFP Topics
Date: Wednesday, April 16, 2003 8:14:42 PM         
   


And if we ignore the nature of the error, the solution is the same:

Instead of
> cString = cString + RECURSIVE(nLevel + 1)

use

c1 = RECURSIVE(nLevel + 1)
cString = cString + c1



> Here is a much shorter program which has the same behaviour. Try to alter the values of gnMaxLevel and gnReplicate. There seems to be a trade-off between them. If gnMaxLevel is higher, gnReplicate can be lower to show a failure.
>
> If you alter the line
>
>
> cString = cString + RECURSIVE(nLevel + 1)
> 

>
> into
>
>
> cString = "" + cString + RECURSIVE(nLevel + 1)
> 

>
> or
>
>
> cString = RECURSIVE(nLevel + 1) + cString
> 

>
> no failure occurs.
>
> Benno.
>
>
>
> PUBLIC gnMaxLevel, gnReplicate
> gnMaxLevel = 6
> gnReplicate = 4
> 
> RECURSIVE(0)
> 
> FUNCTION RECURSIVE()
> 	LPARAMETERS nLevel
> 	LOCAL nLen1, nLen2, cString, cTest, cTest2
> 	
> 	IF nLevel < gnMaxLevel
> 		cString = REPLICATE("+", gnReplicate * 2 ^ (gnMaxLevel - nLevel - 1))
> 
> 		nLen1 = LEN(cString)
> 		cString = cString + RECURSIVE(nLevel + 1)
> 		nLen2 = LEN(cString)
> 		
> 		IF nLen2 < nLen1
> 			? "Failure at level: ", nLevel
> 		ELSE
> 			? "OK at level: ", nLevel
> 		ENDIF
> 	ELSE
> 		cString = REPLICATE("-", gnReplicate)
> 	ENDIF	
> 	
> 	RETURN cString
> ENDFUNC
> 



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