Author Topic: Help with HalBrain.SearchPattern(...) function  (Read 2985 times)

vonsmith

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Help with HalBrain.SearchPattern(...) function
« on: November 12, 2003, 05:53:41 pm »
I'm trying to figure out the syntax of the HalBrain.SearchPattern(...) function.

This works:
Dim Phrase
Phrase = HalBrain.SearchPattern(UserSentence, "* DEFINITION OF *", 2)

This doesn't:
Dim TextString, Phrase
TextString = """* DEFINITION OF *"""
Phrase = HalBrain.SearchPattern(UserSentence, TextString, 2)

Am I doing something wrong or doesn't the HalBrain.SearchPattern(...) function accept variables for the string argument?

Robert Medeksza, Don, onthecuttingedge2005, anyone? Help please.

Thanks,

= vonsmith =
 

Don Ferguson

  • Sr. Member
  • ****
  • Posts: 303
    • View Profile
    • http://www.cortrapar.com
Help with HalBrain.SearchPattern(...) function
« Reply #1 on: November 12, 2003, 10:10:33 pm »
Hello,

I haven't had a chance to experiment with the searchpattern function, but I don't understand what you're doing with the second example (the one that you say doesn't work).  Why do you have three sets of double quotation marks?

I am probably failing to see something obvious.  Could you possibly annotate each line of code, stating your intent for each line?

Sincerely,

Don
« Last Edit: November 13, 2003, 12:35:43 am by Don Ferguson »
Don Ferguson
E-mail: fergusonrkfd@prodigy.net
Website: www.cortrapar.com
Don's other forum posts: http://www.zabaware.com/forum/search.asp?mode=DoIt&MEMBER_ID=274

vonsmith

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Help with HalBrain.SearchPattern(...) function
« Reply #2 on: November 13, 2003, 06:43:21 pm »
Don,
As I understand it you have to use double quotes to quote a quotation mark.

If you do it this way...

text = ""word""
GetResponse = text  --> doesn't print "word" and you will get an error.

Instead...

text = """word"""
GetResponse = text  --> does print "word"

What I'm trying to do is to have HalBrain.SearchPattern(...) work with a string variable and not just a string. This way many various search patterns can be passed to the search function without having a instance of HalBrain.SearchPattern(...) on every line. If I wanted to search 50 patterns it would take 50 lines to do it. If I select string variables from an array of 50 string variables I can just use a For,Next loop and one instance of the HalBrain.SearchPattern(...) function.

Example:

Dim PatternArray
'Initialize array.
PatternArray = Array("""* DEFINITION OF *""","""* WHAT'S ""","""* HOW """)
For I = 0 to 2
   TextString = HalBrain.SearchPattern(UserSentence, PatternArray, 1)
Next


Thanks for the input. I guess I should ask Robert M. if he would publish some info on the various Hal functions.

= vonsmith =