(.brnMaker w/magic spells...>B)
In the past, I've had to make detector .brn's by copying and pasting
files and manually editing...until now! *cues Metallica 'St. Anger for dramatic effect
'PROCESS/RESPOND: .BRN MAKER V0.11
'Hal makes a TopicSearch .brnfile at the User's request
NoBuildFile = DecodeVar(CustomMem, "NoWriteFlag")
If NoBuildFile = "True" Then
BuildFile = "False"
Else
BuildFile = DecodeVar(CustomMem, "WriteFlag")
End If
If Instr (1, OriginalSentence, "done", vbTextCompare) And Len(OriginalSentence) < 12 Then
GetResponse = "I am finished building " & BrainName & "dot BRN."
CustomMem = ""
End If
If Instr (1, OriginalSentence, "make me a brainfile" ,vbTextCompare) > 0 Then
GetResponse = "OK, what do you want the file to be called?"
End If
If Instr (1, PrevSent, "OK, what do you want the file to be called?", vbTextCompare) > 0 Then
BrainName = OriginalSentence
CustomMem = EncodeVar(BrainName, "FileMem")
GetResponse = "What do you want the Boolean to be?"
End If
If Instr (1, PrevSent, "What do you want the Boolean to be?", vbTextCompare) > 0 Then
CustomMem = CustomMem & EncodeVar(OriginalSentence, "BooleMem")
GetResponse = "OK, tell me stuff you want in there. When you're done tell me-"
End If
If Instr (1, PrevSent, "tell me stuff you want in there", vbTextCompare) > 0 Then
BuildFile = "True"
CustomMem = CustomMem & EncodeVar(BuildFile, "WriteFlag")
End If
If BuildFile = "True" Then
BrainName = DecodeVar(CustomMem, "FileMem")
BooleName = DecodeVar(CustomMem, "BooleMem")
HalBrain.AppendFile WorkingDir & Trim(BrainName) & ".brn, """" & OriginalSentence & """" & "," & """" & Trim(BooleName) & """"<---on previous line
GetResponse = "OK, got it. Next-"
End If
------------
-Be sure to have these two Functions at the very end of the UHP script you put this in-
(Mebbe it is a good idea to put this in a Brain that has Hal's normal functioning disabled
for now- I was thinking about the possibility of Hal being able to put the .brn in a
DataFolder of your choice- other than the one Hal is set to --by modifying WorkingDir)
------------
'Decode multiple variables out of a string
Function DecodeVar(FromWhat, DecodeWhat)
Temp = Instr(1, FromWhat, DecodeWhat & "-eq-", vbTextCompare) = Len(DecodeWhat) + 4 '<--------on previous line
Temp2 + Instr(Temp, FromWhat, "-+-", vbTaxtCompare)
If Temp <= Len(DecodeWhat) + 4 Then
DecodeVar = ""
Else
DecodeVar = Mid(FromWhat, Temp, Temp2 - Temp)
End If
End Function
'Encode multiple variables into a string
Function EncodeVar(EncodeWhat, AsWhat)
EncodeVar = AsWhat & "-eq-" & EncodeWhat & "-+-"
End Function
If anyone sees errors, please feel free to fix away.. >B)
CatAtomic