I'm going nuts trying to figure out why some scripts are working and others aren't. The debugger keeps pointing me to the "End Function" at the end of the whole script (like the end of the whole file) -- it says "Expected If" and points to that line.
Here's an example:
THIS SCRIPT WORKS:
----------------------------------
If InStr(UserSentence, " I AM ") > 0 And AvoidBeingFlag = False And InStr(1, OriginalSentence, "
seem To ", vbTextCompare) = 0 Then
BeingPhrase = HalBrain.SearchPattern(UserSentence, "*I AM *", 2)
If Len(BeingPhrase) > 1 And Len(BeingPhrase) < 60 Then
IntroExclaim = ""
If Rnd * 100 < 20 Then IntroExclaim = HalBrain.ChooseSentenceFromFile("introExclaim3")
Encourager = HalBrain.ChooseSentenceFromFile("encourager3")
SuffixComment = ""
If Rnd * 100 < 30 Then SuffixComment = HalBrain.ChooseSentenceFromFile("suffixComment3")
HalBeing = HalBrain.ChooseSentenceFromFile("halBeing")
HalBeing = Replace(HalBeing, "<IntroExclaim>", IntroExclaim, 1, -1, vbTextCompare)
HalBeing = Replace(HalBeing, "<Encourager>", Encourager, 1, -1, vbTextCompare)
HalBeing = Replace(HalBeing, "<BeingPhrase>", BeingPhrase, 1, -1, vbTextCompare)
HalBeing = Replace(HalBeing, "<SuffixComment>", SuffixComment, 1, -1, vbTextCompare)
If Rnd * 100 > 50 Then
IntroExclaim = ""
SuffixComment = ""
Select Case HalBrain.RandomNum(6)
Case 1
GetResponse = " You're " & BeingPhrase & "!"
Case 2
GetResponse = " Your mom's " & BeingPhrase & "!"
Case 3
GetResponse = " You're " & BeingPhrase
Case 4
GetResponse = " Your mom's " & BeingPhrase
Case 5
GetResponse = " You're " & BeingPhrase & "!!"
Case 6
GetResponse = " The whole damn system's " & BeingPhrase & "!!!"
End Select
ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
End If
End If
End If
--------------------------------
BUT THIS SCRIPT DOESN'T:
--------------------------------
If InStr(UserSentence, " I AM ") > 0 And AvoidBeingFlag = False And InStr(1, OriginalSentence, "
seem To ", vbTextCompare) = 0 Then
BeingPhrase = HalBrain.SearchPattern(UserSentence, "*I AM *", 2)
If Len(BeingPhrase) > 1 And Len(BeingPhrase) < 60 Then
SpinWheel = HalBrain.RandomNum(2)
If SpinWheel = 1 Then
IntroExclaim = ""
If Rnd * 100 < 50 Then IntroExclaim = HalBrain.ChooseSentenceFromFile("introExclaim3")
Encourager = HalBrain.ChooseSentenceFromFile("encourager3")
SuffixComment = ""
If Rnd * 100 < 70 Then SuffixComment = HalBrain.ChooseSentenceFromFile("suffixComment3")
HalBeing = HalBrain.ChooseSentenceFromFile("halBeing")
HalBeing = Replace(HalBeing, "<IntroExclaim>", IntroExclaim, 1, -1, vbTextCompare)
HalBeing = Replace(HalBeing, "<Encourager>", Encourager, 1, -1, vbTextCompare)
HalBeing = Replace(HalBeing, "<BeingPhrase>", BeingPhrase, 1, -1, vbTextCompare)
HalBeing = Replace(HalBeing, "<SuffixComment>", SuffixComment, 1, -1, vbTextCompare)
If SpinWheel = 2 Then
IntroExclaim = ""
SuffixComment = ""
Select Case HalBrain.RandomNum(6)
Case 1
GetResponse = " You're " & BeingPhrase
Case 2
GetResponse = " Your mom's " & BeingPhrase
Case 3
GetResponse = " You're " & BeingPhrase
Case 4
GetResponse = " Your mom's " & BeingPhrase
Case 5
GetResponse = " Your ass " & "!"
Case 6
GetResponse = " The whole damn system's " & BeingPhrase & "!!!"
End Select
ShortPhrase = "" 'If Hal was to make a comment about short phrases, clear it
End If
End If
End If
----------------------------------------
I'm trying to analyze and emulate what I see elsewhere in the original script, since I really know nothing about scripting (I'm learning, though

). But this problem KEEPS cropping up. It's analogous to several other similar problems. Apparently, I can use Select Case and SpinWheel at some "levels" and not others (as shown above) -- am I forgetting something? Am I not setting it up right? It seems to be the same case. I can post another similar case if this doesn't illustrate the recurring problem well. I *want* the latter example, not the former (as the former is set up, my two cases sometimes overlap, and I don't want them to).