How do I search each of these keywords from a single text field?

I've got a single form field where the user can enter multiple keywords to search from.

Using BASIC how would I parse these out so I can query each of them?

This is in UniBasic if that helps.
Donnie WalkerAsked:
Who is Participating?
 
mensoidCommented:
dim words()
redim words(0)
stpoint=1
for x=1 to len(txtsearch)
    if substring(txtsearch,1,1)=" " then
          words(ubound(words))=substring(txtserach,stpoint,x-1)
           redim preserve words(ubound(words)+1)
           stpoint=x+1
    end if
next x

if there is no redim preserve options:
dim words(maxcount)
wrdcnt=0
stpoint=1
for x=1 to len(txtsearch)
    if substring(txtsearch,1,1)=" " then
          words(wrdcnt)=substring(txtserach,stpoint,x-1)
           wrdcnt=wrdcnt+1
           stpoint=x+1
    end if
next x

I just looked att he syntax for uniBasic.. if you can't make the syntax changes needed let me know I'll re-write in that specifc dialict
0
 
Paul MacDonaldDirector, Information SystemsCommented:
Can't speak to UniBasic, but in VB.Net I'd take the whole string and SPLIT it on the spaces (between words), putting each section/word in an array so each word could be used individually.
0
 
Donnie WalkerAuthor Commented:
can you give me an example?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
VBClassicGuyCommented:
0
 
mensoidCommented:
Example of PaulMacD's answer, making a change to split on "," instead of spaces
given:
form field=txtSearch
instructions to user are to comma sperate search words (in case one word has a space in it)

dim keywords()
keywords=split(txtsearch,",")
ado.open "Select * from Mytable where myfield like('%"+join(keywords,"%'), or myfield like ('%")+"%')",adodc

results, if the txtsearch ="value1,value2" you be running a query of:
Select * from Mytable where myfield like('%value1%') or myfield like('%value2%')
0
 
Donnie WalkerAuthor Commented:
split is not available as a command in UniBasic. I haven't found anything comparable.

Is there a another way to do this using Basic Programming?
0
 
Paul MacDonaldDirector, Information SystemsCommented:
Is there a "substring" equivilent?  That is, can you search for commas, then grab the portion of the string between the last comma and the next one?  

This could be done by looping through the string from the beginning, looing for a comma.  When you find (the first) one, grab the portion of the string from the beginning to the comma, store it in an array, then start searching for the next comma from one character after the comma you just found.  If you reach the end of the string, you have your last term.
0
 
Donnie WalkerAuthor Commented:
Yes, there is a substring command. Can you give me an example that would look for spaces and parse out the words for searching?
0
 
Donnie WalkerAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.