Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SubStr() and Left()
Message
From
23/08/2002 20:32:17
 
 
To
23/08/2002 20:01:26
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00693205
Message ID:
00693210
Views:
19
I don't think there's a difference between the two, especially reading the note at the end of LEFT() in the Help.

You never did say the nature of the problem that was fixed.

I would suspect that it more had to do with your customer's data, and specifically the first field it hit for field5 that qualified for the WHERE.
If the first qualifying field5 was empty or had only say 6 characters, then ALL SUBSEQUENT field5's listed would also be limited to that same number of characters.

cheers


>I just ran into a very odd situation today. This app is a VFP6 SP5 app. I'm converting it, but until I'm satisfied, it remains as is.
>
>Anyway, I was working on a bug in the app that seemed to affect only one of our clients. For whatever reason, the former programmer used Substr(cVar, 1, 24) to pull the first 24 characters out of a memo field in an Select - SQL call. The code concatenated 5 fields into element 1 of an array.
>
>ie:
>
Select field1 + " " + field2 + " " + field3 + " " + field4 + " " + ;
>  Substr(StrTran(field5, Chr(13) + Chr(10), " "), 1, 24) from table1 ;
>  into array aString
>
>There is also a where clause, but it's not significant.
>
>The bug manifested in the fact that regardless of what was in the memo field (field5), only the 1st 4 fields were showing up in the array. It was as if the 5th field always returned a blank even if the memo field contained data.
>
>I fixed the problem (don't ask me why I even tried this, because I don't have an answer), by replacing
>
>
Substr(StrTran(field5, Chr(13) + Chr(10), " "), 1, 24)
>with
>
Left(StrTran(field5, Chr(13) + Chr(10), " "), 24)
>
>Does anyone out there have even a glimmer of a clue why Left() worked when SubStr() wouldn't? Remember too, that this only makes a difference on one client's data. As far as I can tell, Substr() works fine on my test data and our other client's data. Finally, I can't see any difference in this client's data from anyone else's.
>
>Is there a difference in result between Substr(cVar, 1, 24) and Left(cVar, 24) that I don't know about?
>
>Any light shed on this would be appreciated.
>
>Alan
Previous
Reply
Map
View

Click here to load this message in the networking platform