TC Fact v1.0 10-21-05 for Ultra Hal5.0 This script will allow Hal to store and recall simple facts on command. To store a fact (for example), you can type.... Fact: My name is John. Hal will say "I've noted your Fact" To later recall a fact you can type... Fact: What is my name? Hal will search your personal fact file for an answer. The key feature in using this script is to word your facts carefully so you can remember the key words to use to retrieve the fact you want. The above example was easy. Remembering to include the words "my name" is the key to finding the proper fact. Hal simply uses the text before the word "is" when you state a fact, then uses that exact text to find the fact when you need it. I admit, it's a bit crude but hey, I'm still learning this stuff. :) I welcome any comments about this script, either good or bad. I can be reached on the Zabaware fourms or if you perfer, email me at tdcoday@wmconnect.com Now on to the script code. First search your Hal Brain file for... 'WRITE NEW QA DATA TO FILES: Insert a couple of blank lines before "'WRITE NEW QA DATA TO FILES:" then copy and paste the next to lines there. ********** copy start *************************** 'TC Fact v1.0 Set BlockSave = True to prevent Facts being written to general learning files. If InStr(1, UserSentence, "FACT : ", 1) > 0 Then BlockSave = True ********** copy end ***************************** Now search your Hal Brain file for....... 'HalFormat the GetResponse to clean up a few things before proceeding. Again, Insert a couple of blank lines before " 'HalFormat the GetResponse to clean up a few things before proceeding. " then copy and paste the rest of the script there. ********** copy start *************************** 'TC Fact Script v1.0 10-21-05 If InStr(1, UserSentence, "FACT : ", 1) > 0 Then FactData = " " & UserSentence & " " FactData = Replace(FactData, "FACT :", " ", 1, 1) FactData = Trim(FactData) If InStr(1, FactData, "WHAT ", 1) = 0 Then IsPosition = InStr(1, FactData, " is ", 1) IsPosition = IsPosition + 3 FactDataLength = Len(FactData) FactSubject = Left(FactData, IsPosition) FactInfo = Right(FactData, FactDataLength - IsPosition) RTrim(FactSubject) HalBrain.AppendFile WorkingDir & Trim(UserName) & "_Fact_file.brn", """" & " " & LCase(FactSubject) & "" & """,""" & " " & FactSubject & FactInfo & " " & """" GetResponse = "I've noted your Fact." End If If InStr(1, FactData, "WHAT ", 1) > 0 Then FactData = Replace(FactData, "?", " ", 1, 1) IsPosition = InStr(1, FactData, " is ", 1) IsPosition = Isposition + 3 FactDataLength = Len(FactData) FactSearch = Right(FactData, FactDataLength - IsPosition) FactSearch = FactSearch & " is " FactSearchResult = HalBrain.TopicSearch(FactSearch, WorkingDir & Trim(UserName) & "_Fact_file.brn") If Len(FactSearchResult) < 2 Then GetResponse = "I'm sorry, I couldn't find that FACT in my notes." Else GetResponse = FactSearchResult End If End If End If 'End of TC Fact Script ************************************************************************ ********** copy end ***************************** That's it, you're all done. Save your brain file and try it out. Extra notes: This script was written and tested in Vonsmith's XTF 1.2 brain file. If you're using the default brain, or any other brain, things should still work as expected, although you'll have to pick and choose where to insert the code. I'd recommend putting the first part of this script near the top after the deductive learning code. Then paste the second larger portion of the script in the lower part of the brain, just before the GetResponse clean up code.