Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String to Char Array...
Message
From
03/11/2000 17:29:41
 
 
To
03/11/2000 14:17:39
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00437794
Message ID:
00437880
Views:
26
>Hello to all!
>
>I'm a Java and a C programmer so I'm used to seeing strings as character arrays. I was wondering if the same thing existed in FoxPro?
>
>Basically, if I try to explain what I'm trying to do, I want to compare two strings together and return a percentage that represents how identical they both are. For this, I have to compare each of the two words letter by letter. I haven't found a better way to do this than by using the function SUBSTR() inside a FOR loop. I think that this method is not optimal (there MUST be a better way to return 1 character from a string at a specified position than SUBSTR()!).
>
>Anyway, I must use FoxPro for this because of how fast it is with text. So I sure hope I'll find a way to run this application that'll exploit FoxPro's strengths.
>
>Thanks a lot in advance, Stephane.

Unfortunately SUBTR() is it as far as byte by byte character location within a string in FoxPro. I haven't really given this much thought but.... You could create a one character single field cursor

CREATE CURSOR whatever (somefield c(1))

put your string in a file using STRTOFILE() and APPEND FROM ... SDF into the cursor. Each character in the string would then be a record in the cursor. You could refer to the character position by record number in the cursor. Then you would have FoxPro's real strengths at your disposal. This could be both slow and wasteful or it might be worth some further thought.
HTH
Previous
Reply
Map
View

Click here to load this message in the networking platform