[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

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.
0
Donnie Walker
Asked:
Donnie Walker
  • 4
  • 2
  • 2
  • +1
1 Solution
 
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
 
VBClassicGuyCommented:
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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
 
Donnie WalkerAuthor Commented:
Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now