Link to home
Start Free TrialLog in
Avatar of Donnie Walker
Donnie WalkerFlag for United States of America

asked on

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.
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

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.
Avatar of Donnie Walker

ASKER

can you give me an example?
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%')
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?
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.
Yes, there is a substring command. Can you give me an example that would look for spaces and parse out the words for searching?
ASKER CERTIFIED SOLUTION
Avatar of mensoid
mensoid
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks