Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Possible bug
Message
From
28/12/2001 10:26:48
Keith Payne
Technical Marketing Solutions
Florida, United States
 
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00598533
Message ID:
00598800
Views:
42
Thank you everyone for your input. This thread has creeped away from the original problem. The string was "Keith James Payne" which had 2 spaces between the first and second words and 2 spaces between the second and third words. If there were 3 spaces between 2 words, I agree that STRTRAN() should not convert all 3 spaces into a single space. However, this is not the case in the code I presented.

The help from VFP7 specifically states that *each* occurence of the expression will be replaced. Additionaly, simple tests demonstrate that STRTRAN() does work correctly with a literal string, memvar and property, but does not work correctly in the code from the class I am working on.

- Keith

<snip>

>>
>>Hi Nadya
>>
>>Sorry but you appear to be missing the same point. This is not a bug, the only way it could possibly be a bug is if STRTRAN() were recursive, which it isn't.
>>
>>Consider the following string:
>>
>>"A B" (A, 3 spaces, B)
>>
>>Use STRTRAN() to replace all occurrences of double spaces with single. How many occurrences of two spaces are there in this string? The answer is that there is only ONE occurrence. The result is, therefore:
>>
>>"A B" (A 2 spaces B)
>>
>>However, AFTER the first pass we still have a double space because the first operation created one (the replacement single space PLUS the original single space).
>>
>>It's not a bug, but you do need to use it correctly, like this:
>>
>>lcStr = "A B"
>>? STRTRAN( STRTRAN( lcStr, " ", " " ), " ", " " )
>
>Yep, and this solves two passes, so have the single STRTRAN in a loop ;)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform