Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Query a database with multiple pieces of data
#1
Need to split a string into pieces of data that will query a database:

Figure I'll use something like sel and case...the problem I see using that is I would rather maintain text files with the words in them so I can edit without having to touch the code in QM and restart the macro with the updated word list.

First off:
Is there anything that works like sel and case that I can set up using variables instead of constants?
Help file says only constants...so is there something similar that I don't know about?

Here's a basic example:
Code:
Copy      Help
str SelWord="One"
str CaseWordListEven=
;Two
;Four
;Six
;Eight
;Ten
str CaseWordListOdd=
;One
;Three
;Five
;Seven
;Nine
sel SelWord 1
,case CaseWordListEven
,out "Even"
,case CaseWordListOdd
,out "Odd"
,case else out "No Match"

Here's an example of splitting data using sel and case (this one does work):
I figure it could go something like this
Code:
Copy      Help
out
str SearchWord="is dinner going to be at 7:00pm tomorrow"

str Meal
str Day
;Search
sel SearchWord 1|2
,case ["*breakfast*"]
,Meal="breakfast"
,SearchWord.findreplace("breakfast" "" 4|1)
,goto Search
,case ["*lunch*"]
,Meal="lunch"
,SearchWord.findreplace("lunch" "" 4|1)
,goto Search
,case ["*dinner*"]
,Meal="dinner"
,SearchWord.findreplace("dinner" "" 4|1)
,goto Search
,case ["*yesterday*"]
,Day="yesterday"
,SearchWord.findreplace("yesterday" "" 4|1)
,goto Search
,case ["*today*"]
,Day="today"
,SearchWord.findreplace("today" "" 4|1)
,goto Search
,case ["*tomorrow*"]
,Day="tomorrow"
,SearchWord.findreplace("tomorrow" "" 4|1)
,goto Search
,
out Meal
out Day

I need it to be a bit more complicated:
Code:
Copy      Help
str SearchWord="Who's Bobby w/2nite?"
str Day Person
;Search
sel SearchWord 1|2
,case ["*tonight*","*2nite*","*tonight*","*2nit*","*now*"]
,Day="tonight"
,;;Need to romove from SearchWord("*tonight*","*2nite*","*tonight*","*2nit*","*now*")
,goto Search

,case ["*bobby Darin*","*bobbie Darin*"]
,str Person="Bobby"
,;;Need to romove from SearchWord("bobby darin","bobbie darin")
,goto Search

out Day
out Person

So the data base will have different keys that I'll search. In the example above, Day and Person. The query will be able to be asked in a sentence and will be able to contain misspellings (That's what the word lists will be for, which is why I want them to be external, because I plan on monitoring what people are searching and adding to the lists as the program gets used. That way it can get smarter!)

So I need cases that work from text stored in a file
I need to remove what ever the case matches from the text file.

Hopefully this is enough information so someone can see what I am trying to do...
Please help...I may even be totally off track and there is an easier way of doing all this.

Thanks,
Jimmy Vig


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)