Well I haven't done it, and it might not be called 'slick' but how 'bout something like:
set var vsearchword text = 'string'
set var vstring text = 'This is a test string to demonstrate what I want to do'
set var vstring2 text = (SRPL(.vstring,' ',',',0)) -- replace the spaces with the delimiter (rather than changing the delimiter - either way I guess)
set var vwordcount integer = (itemcnt(.vstring2)) -- total number of words
set var vcurrentcount integer = 1 -- start at one
set var vwordposition integer = 0 -- this will be the search word's position
set var vcurrentword text = null
LABEL toploop
While vcurrentcount < .vwordcount
set var vcurrentword = (ssub(.vstring,.vcurrentcount)) -- if you've changed the delimiter to a space, change vcurrentcount to a negative (.vcurrencount * -1))
IF vcurrentword = .vsearchword then
-- this is your word number
set var vwordposition = .vcurrentcount
set var vcurrentcount = .vwordcount
ENDIF
set var vcurrentcount = (.vcurrentcount + 1) -- goto next word
endwhile
Now this only finds the word position for the first time the word appears in the string. You'll have to rework it a little to find multiple positions of the same word.
-------------- Original message from "Paul Buckley" <[email protected]>: --------------
> Good Morning All,
>
> I'm wondering if anyone else has done this and is willing to share. I'm
> working on a project using V8 Turbo. I'm going to be counting the number of
> words in a description text string for over 500,000 rows of data and I need
> to know the relative "word" position of words in the string. For example;
> if the string is 'This is a test string to demonstrate what I need to do.',
> it has 12 words and the word 'string' is the 5th word and the word
> 'demonstrate' is the 7th word.
>
> I know I can use the ItemCnt function to count the number of words, by first
> changing the delimiter to a space. I'm looking for a slick way to find a
> words relative position by word count.
>
> If anyone has any suggestions or insight I would greatly appreciate it.
>
> Thanks in advance,
> Paul Buckley
>
> --- RBASE-L
> ================================================
> TO POST A MESSAGE TO ALL MEMBERS:
> Send a plain text email to [email protected]
>
> (Don't use any of these words as your Subject:
> INTRO, SUBSCRIBE, UNSUBSCRIBE, SEARCH,
> REMOVE, SUSPEND, RESUME, DIGEST, RESEND, HELP)
> ================================================
> TO SEE MESSAGE POSTING GUIDELINES:
> Send a plain text email to [email protected]
> In the message SUBJECT, put just one word: INTRO
> ================================================
> TO UNSUBSCRIBE:
> Send a plain text email to [email protected]
> In the message SUBJECT, put just one word: UNSUBSCRIBE
> ================================================
> TO SEARCH ARCHIVES:
> Send a plain text email to [email protected]
> In the message SUBJECT, put just one word: SEARCH-n
> (where n is the number of days). In the message body,
> place any
> text to search for.
> ================================================
>
>

