Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Extract a Word
Message
From
12/07/2001 08:09:07
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
12/07/2001 08:03:42
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00529297
Message ID:
00529617
Views:
9
>>Is there a quick way to extract a "Word" from a string? I thought there were functions similar to WordCount() and WordNum(), but I can't find them.
>>
>>The idea is to do something like this:
>>
>>
>>MyString = "Option 1;Option 2;Option3"
>>for i = 1 to WordCount(MyString, ",")
>>  ? WordNum(MyString, i, ",")
>>next
>>
>>
>>Regards, Hilmar.
>
>Hilmar,
>Words(), WordNum() are part of foxtools.fll but wordnum() runs slow. A faster approach is another custom fll if words expected to be more than 65000 or alines() :
>
>lnWordCount = alines(arrWords,chrtran(lcString, lcDelimiter, chr(13)))
>for i = 1 to lnWordCount
> ? arrWords[i]
>endfor
Cetin

BTW if lcString has empty values (ie: 'hello,,,there') this approach and wordnum() misses them. Workaround with alines :
lnWordCount = alines(arrWords,strtran(lcString, lcDelimiter, chr(13)+chr(10)))
for i = 1 to lnWordCount
 ? arrWords[i]
endfor
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform