Jump to content

I get a wierd error...


Recommended Posts

ok, so, I am trying to make a bot. It will read its commands from a file called brain.aiml (AIML, the Artificial Intelligence Markup Language, is essentially just XML).

But when I run it, SCiTE gives me this error:

C:\Documents and Settings\Matt Roth\My Documents\AutoIt\XML.au3 (89) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$sz_sp2 = StringSplit($sz_sp1[$i_occurance + 1], $sz_after, 1) 
$sz_sp2 = StringSplit(^ ERROR

Here is the script:

#include "XML.au3"
#include <GUIConstants.au3>
#include <Misc.au3>
#include <Array.au3>

MsgBox (64, "AIML Bot", "Welcome to the AIML Bot made in AutoIt. Your bot is being prepared.")

Global $contents = _XMLLoad("brain.aiml")

Global $categories_num = __StringNumOccur ($contents, "<category>")

Global $patterns[$categories_num], $templates[$categories_num]

If $categories_num = 0 Then Exit MsgBox (48, "AIML Bot", "AIML Syntax Error:"&@CRLF&@CRLF&"There are no <category> tags. Please check your code and try again.")
If $categories_num > __StringNumOccur ($contents, "</category>") Then Exit MsgBox (48, "AIML Bot", "AIML Syntax Error:"&@CRLF&@CRLF&"There is one or more <category> tag without an ending </category> tag. Please check your code and try again.")
If $categories_num < __StringNumOccur ($contents, "</category>") Then Exit MsgBox (48, "AIML Bot", "AIML Syntax Error:"&@CRLF&@CRLF&"There is one or more extra </category> tags without beginning <category> tags. Please check your code and try again.")

$botinfo = _XMLGet ($contents, "botinfo")
If @error Then Exit MsgBox (48, "AIML Bot", "AIML Syntax Error:"&@CRLF&@CRLF&"There is no <botinfo> tag. This tag should contain a <name> tag with the name of your bot, and an <unknown> tag containing your bot's default response for when a user inputs a message that is unknown to the bot. Please check your code and try again.")

$bot_name = _XMLGet ($botinfo, "name")
If @error Then Exit MsgBox (48, "AIML Bot", "AIML Syntax Error:"&@CRLF&@CRLF&"There is no <name> tag inside your <botinfo> tag. The <name> tag should contain the bot's name. Please check your code and try again.")

$bot_name = _XMLGet ($botinfo, "unknown")
If @error Then Exit MsgBox (48, "AIML Bot", "AIML Syntax Error:"&@CRLF&@CRLF&"There is no <unknown> tag inside your <botinfo> tag. The <name> tag should contain your bot's default response for when a user inputs a message that is unknown to the bot. Please check your code and try again.")

For $i=1 To $categories_num
    $cat_contents = _XMLGet ($contents, "category", $i)
    $cat_pattern = _XMLGet ($cat_contents, "pattern")
    If @error Then Exit MsgBox (48, "AIML Bot", "AIML Syntax Error:"&@CRLF&@CRLF&"Category number "&$i&" does not have a <pattern> tag. Please check your code and try again.")
    If $cat_pattern = "" Then Exit MsgBox (48, "AIML Bot", "AIML Syntax Error:"&@CRLF&@CRLF&"The <pattern> tag in category number "&$i&" is empty. Please check your code and try again.")
    $patterns[$i] = $cat_pattern
    $cat_template = _XMLGet ($cat_contents, "template")
    If @error Then Exit MsgBox (48, "AIML Bot", "AIML Syntax Error:"&@CRLF&@CRLF&"Category number "&$i&" does not have a <template> tag. Please check your code and try again.")
    If $cat_template = "" Then Exit MsgBox (48, "AIML Bot", "AIML Syntax Error:"&@CRLF&@CRLF&"The <template> tag in category number "&$i&" is empty. Please check your code and try again.")
    $templates[$i] = $cat_template
Next

GUICreate ( "AIML Bot", 390, 210 )
$input = GUICtrlCreateEdit("", 10, 10, 175, 150, $WS_VSCROLL)
$history = GUICtrlCreateEdit("Please type in the input field at the bottom."&@CRLF&"---------------", 200, 10, 175, 150, BitOR($WS_VSCROLL, $ES_READONLY))
$Sbutton = GUICtrlCreateButton("Say", 145, 165, 100, 35)
$exit = GUICtrlCreateButton("Exit", 270, 165, 150, 35)

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    ElseIf $msg = $Sbutton Or _IsPressed ("0D") = 1 Then
        $Text = GUICtrlRead($input)
        If $Text <> "" Then
            $response = AIML_Respond ($Text)
            GUICtrlSetData ( $history, GUICtrlRead ($history) & @CRLF & "You: " & $Text & @CRLF & $bot_name & $response )
        EndIf
        GUICtrlSetData ($input, "")
    ElseIf $msg = $exit Then
        If MsgBox ( 36, "Disconnect", "Are you sure you want to quit?") = 6 Then Exit
    EndIf
WEnd

Func AIML_Respond ($message)
    $pos = _ArraySearch ($pattern, $message)
    If $pos = -1 Then
        $response = $unknown_reply
    ElseIf $pos = 0
        $response = $unknown_reply
    Else
        $response = $templates[$pos]
    EndIf
    Return $response
EndFunc

And here is XML.au3:

Func _XMLStart ($version = "1.0", $encoding="ISO-8859-1")
    Return '<?xml version="'&$version&'" encoding="'&$encoding&'"?>'&@CRLF
EndFunc

Func _XMLSet(ByRef $s_xml, $s_ele, $s_node)
    If _XMLExists($s_xml, $s_ele) Then _XMLDel($s_xml, $s_ele)
    $s_xml = $s_xml & "<" & $s_ele & ">" & $s_node & "</" & $s_ele & ">" & @CRLF
EndFunc

Func _XMLGet($s_xml, $s_ele, $occurance = 1)
    If not _XMLExists($s_xml, $s_ele) Then
        SetError(1)
        Return ""
    EndIf
    Return __StringParse($s_xml, "<" & $s_ele & ">", "</" & $s_ele & ">", $occurance)
EndFunc

Func _XMLDel(ByRef $s_xml, $s_ele)
    If not _XMLExists($s_xml, $s_ele) Then
        SetError(1)
        Return ""
    EndIf
    StringReplace("<" & $s_ele & ">" & _XMLGet($s_xml, $s_ele) & "</" & $s_ele & ">" & @CRLF, "", 0, 1)
EndFunc

Func _XMLExists($s_xml, $s_ele)
    If StringInStr($s_xml, "<" & $s_ele & ">") and StringInStr($s_xml, "</" & $s_ele & ">") Then Return 1
    Return 0
EndFunc

Func _XMLSave($s_xml, $s_file)
    Local $xml_open = FileOpen ($s_file, 2)
    FileWrite($xml_open, $s_xml)
    FileClose($xml_open)
    Return not @error
EndFunc

Func _XMLLoad($s_file)
    Return __FileReadAll($s_file)
EndFunc

Func _XMLStartSection(ByRef $s_xml, $s_secname)
    $s_xml = $s_xml & "<" & $s_secname & ">" & @CRLF
EndFunc

Func _XMLEndSection(ByRef $s_xml, $s_secname)
    $s_xml = $s_xml & "</" & $s_secname & ">" & @CRLF
EndFunc

Func XMLGetVersion($s_xml)
    Return __StringParse ($s_xml, '<?xml version="', '"', 1)
EndFunc

;############################
;#   Helper Functions    #
;############################

Func __FileReadAll($s_file)
    If not FileExists($s_file) Then
        SetError(1)
        Return ""
    EndIf
    Return FileRead($s_file, FileGetSize($s_file))
EndFunc

Func __Test($b_Test, $v_True = 1, $v_False = 0)
    If $b_Test Then Return $v_True
    Return $v_False
EndFunc

Func __StringNumOccur($sStr1, $sStr2)
    If Not StringInStr ($sStr1, $sStr2) Then Return 0
    For $i = 1 to StringLen($sStr1)
        If not StringInStr($sStr1, $sStr2, 1, $i) Then ExitLoop
    Next
    Return $i
EndFunc

Func __StringParse($sz_str, $sz_before, $sz_after, $i_occurance = 0)
    Local $sz_sp1 = StringSplit($sz_str, $sz_before, 1)
    If $i_occurance < 0 or $i_occurance > $sz_sp1[0] Then
        SetError(1)
        Return ""
    EndIf
    Local $sz_sp2
    If $i_occurance = 0 Then
        $sz_sp2 = StringSplit($sz_sp1[$sz_sp1[0]], $sz_after, 1)
    Else
        $sz_sp2 = StringSplit($sz_sp1[$i_occurance + 1], $sz_after, 1)
    EndIf
    Return $sz_sp2[1]
EndFunc ;==>_StringParse()

What is happening here?

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

  • Developers

Without have to copy past all info: Did you check the Ubound of $sz_sp1 if it was at least 1 higher than: $i_occurance + 1 ?

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

what is a Ubound anyway? and how do I check it?

The Ubound tells you the number of entries in an Array... HelpFile :lmao:

You are trying to retrieve the value of an Array entry that doesn't exists so thats why you get the error ...

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

oh wait...

i added this line in __StringParse

MsgBox (0, "info", "Ubound of $sz_sp1 is: "&UBound($sz_sp1)&" and $i_occurance is: "&$i_occurance)

and it says the Ubound is 3 and $i_occurance is 1

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

if it matters, here is brain.aiml:

<?xml version="1.0" encoding="ISO-8859-1"?>

<aiml>
    <botinfo>
        <name>MyBot</name>
        <unknown>I'm Sorry. I did not understand what you said. Please try again.</unknown>
    </botinfo>
    
    <category>
        <pattern>hello</pattern>
        <template>Hi there!</template>
    </category>
</aiml>

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

  • Developers

oh wait...

i added this line in __StringParse

MsgBox (0, "info", "Ubound of $sz_sp1 is: "&UBound($sz_sp1)&" and $i_occurance is: "&$i_occurance)

and it says the Ubound is 3 and $i_occurance is 1

Did you put this msgbox() before the line giving the error ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Oh, I know. It will always detect one more categories than there really are. So in that brain.aiml file I posted, there is only one <category> but $categories_num is 2.

Why would it do this?

edit: fixed that. Still get the same error...

Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

  • Developers

dunno were you put the msgbox but i added 2 consolewrite debug lines before the statement that errors out end here is the dump:

@@ Debug(89) : UBound($sz_sp1) = 3

>Error code: 0 Extended code: 0

@@ Debug(90) : $i_occurance = 2

>Error code: 0 Extended code: 0

C:\Development\winutil\AutoIt3\programs\test\XML.au3 (91) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$sz_sp2 = StringSplit($sz_sp1[$i_occurance + 1], $sz_after, 1)

$sz_sp2 = StringSplit(^ ERROR

So:

UBound($sz_sp1) = 3 (equals to these three possible values: 0,1,2)

$i_occurance = 2

$sz_sp1[$i_occurance + 1] = $sz_sp1[3] = KABOOM!!!!!

:lmao:

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

ohh ok :lmao: thanks. I was thinking that since the Ubound was 3 then $sz_sp1[3] was valid. That was a little stupid of me ;)

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

wait. it is not detecting the AIML Code correctly. I added ConsoleWrite()'s after all the _XMLGet()'s and made ait so that an AIML Syntax Errow would still msgbox() but not exit, using this code now:

$botinfo = _XMLGet ($contents, "botinfo")
If @error Then MsgBox (48, "AIML Bot", "AIML Syntax Error:"&@CRLF&@CRLF&"There is no <botinfo> tag. This tag should contain a <name> tag with the name of your bot, and an <unknown> tag containing your bot's default response for when a user inputs a message that is unknown to the bot. Please check your code and try again.")
ConsoleWrite ( '_XMLGet($contents, "botinfo") returned: '&$botinfo&@CRLF )

$bot_name = _XMLGet ($botinfo, "name")
If @error Then MsgBox (48, "AIML Bot", "AIML Syntax Error:"&@CRLF&@CRLF&"There is no <name> tag inside your <botinfo> tag. The <name> tag should contain the bot's name. Please check your code and try again.")
ConsoleWrite ( '_XMLGet($botinfo, "name") returned: '&$bot_name&@CRLF )

$unknown_reply = _XMLGet ($botinfo, "unknown")
If @error Then MsgBox (48, "AIML Bot", "AIML Syntax Error:"&@CRLF&@CRLF&"There is no <unknown> tag inside your <botinfo> tag. The <name> tag should contain your bot's default response for when a user inputs a message that is unknown to the bot. Please check your code and try again.")
ConsoleWrite ( '_XMLGet($botinfo, "unknown") returned: '&$unknown_reply&@CRLF )

Here is what ConsoleWrite() gives:

_XMLGet($contents, "botinfo") returned: <?xml version="1.0" encoding="ISO-8859-1"?>



<aiml>

    

_XMLGet($botinfo, "name") returned: 

_XMLGet($botinfo, "unknown") returned:

I also get AIML Syntax Errors for there being no <name> or <unknown> tags inside my <botinfo> tag.

here is brain.aiml:

<?xml version="1.0" encoding="ISO-8859-1"?>

<aiml>
    <botinfo>
        <name>MyBot</name>
        <unknown>I'm Sorry. I did not understand what you said. Please try again.</unknown>
    </botinfo>
    
    <category>
        <pattern>hello</pattern>
        <template>Hi there!</template>
    </category>
    
    <category>
        <pattern>What is your name?</pattern>
        <template>I am &botname;. Who are you?</template>
    </category>
</aiml>

As you can see, there is obviously a <name> and <unknown> tag inside the <botinfo> tag.

I find it strange that When I _XMLGet($contents, "botinfo") it returns the very first and last lines of the fil. What is wrong here?

Oh, and here is __StringParse():

Func __StringParse($sz_str, $sz_before, $sz_after, $i_occurance = 0)
    Local $sz_sp1 = StringSplit($sz_str, $sz_before, 1)
    If $i_occurance < 0 or $i_occurance > $sz_sp1[0] Then
        SetError(1)
        Return ""
    EndIf
    Local $sz_sp2
    If $i_occurance = 0 Then
        $sz_sp2 = StringSplit($sz_sp1[$sz_sp1[0]], $sz_after, 1)
    Else
        $sz_sp2 = StringSplit($sz_sp1[$i_occurance], $sz_after, 1)
    EndIf
    Return $sz_sp2[1]
EndFunc ;==>_StringParse()

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

  • Developers

What did you change in xml.au3 ?

When i run the following with the original xml.au3, things seem to work:

#include "XML.au3"
$contents = _XMLLoad("brain.aiml")
_XMLGet($contents, "botinfo")
ConsoleWrite('@@ Debug(5) : _XMLGet($contents,"botinfo") = ' & _XMLGet($contents,"botinfo") & @lf & '>Error code: ' & @error & '    Extended code: ' & @extended & @lf);### Debug Console

Returns:

@@ Debug(5) : _XMLGet($contents,"botinfo") =

<name>MyBot</name>

<unknown>I'm Sorry. I did not understand what you said. Please try again.</unknown>

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

here is my xml.au3:

Func _XMLStart ($version = "1.0", $encoding="ISO-8859-1")
    Return '<?xml version="'&$version&'" encoding="'&$encoding&'"?>'&@CRLF
EndFunc

Func _XMLSet(ByRef $s_xml, $s_ele, $s_node)
    If _XMLExists($s_xml, $s_ele) Then _XMLDel($s_xml, $s_ele)
    $s_xml = $s_xml & "<" & $s_ele & ">" & $s_node & "</" & $s_ele & ">" & @CRLF
EndFunc

Func _XMLGet($s_xml, $s_ele, $occurance = 1)
    If not _XMLExists($s_xml, $s_ele) Then
        SetError(1)
        Return ""
    EndIf
    Return __StringParse($s_xml, "<" & $s_ele & ">", "</" & $s_ele & ">", $occurance)
EndFunc

Func _XMLDel(ByRef $s_xml, $s_ele)
    If not _XMLExists($s_xml, $s_ele) Then
        SetError(1)
        Return ""
    EndIf
    StringReplace("<" & $s_ele & ">" & _XMLGet($s_xml, $s_ele) & "</" & $s_ele & ">" & @CRLF, "", 0, 1)
EndFunc

Func _XMLExists($s_xml, $s_ele)
    If StringInStr($s_xml, "<" & $s_ele & ">") and StringInStr($s_xml, "</" & $s_ele & ">") Then Return 1
    Return 0
EndFunc

Func _XMLSave($s_xml, $s_file)
    Local $xml_open = FileOpen ($s_file, 2)
    FileWrite($xml_open, $s_xml)
    FileClose($xml_open)
    Return not @error
EndFunc

Func _XMLLoad($s_file)
    Return __FileReadAll($s_file)
EndFunc

Func _XMLStartSection(ByRef $s_xml, $s_secname)
    $s_xml = $s_xml & "<" & $s_secname & ">" & @CRLF
EndFunc

Func _XMLEndSection(ByRef $s_xml, $s_secname)
    $s_xml = $s_xml & "</" & $s_secname & ">" & @CRLF
EndFunc

Func XMLGetVersion($s_xml)
    Return __StringParse ($s_xml, '<?xml version="', '"', 1)
EndFunc

;############################
;#   Helper Functions    #
;############################

Func __FileReadAll($s_file)
    If not FileExists($s_file) Then
        SetError(1)
        Return ""
    EndIf
    Return FileRead($s_file, FileGetSize($s_file))
EndFunc

Func __Test($b_Test, $v_True = 1, $v_False = 0)
    If $b_Test Then Return $v_True
    Return $v_False
EndFunc

Func __StringNumOccur($sStr1, $sStr2)
    If Not StringInStr ($sStr1, $sStr2) Then Return 0
    For $i = 1 to StringLen($sStr1)
        If not StringInStr($sStr1, $sStr2, 1, $i) Then ExitLoop
    Next
    Return $i-1
EndFunc

Func __StringParse($sz_str, $sz_before, $sz_after, $i_occurance = 0)
    Local $sz_sp1 = StringSplit($sz_str, $sz_before, 1)
    If $i_occurance < 0 or $i_occurance > $sz_sp1[0] Then
        SetError(1)
        Return ""
    EndIf
    Local $sz_sp2
    If $i_occurance = 0 Then
        $sz_sp2 = StringSplit($sz_sp1[$sz_sp1[0]], $sz_after, 1)
    Else
        $sz_sp2 = StringSplit($sz_sp1[$i_occurance], $sz_after, 1)
    EndIf
    Return $sz_sp2[1]
EndFunc ;==>_StringParse()

I had to change things around because there would be more than one <category> and the original would always return the first one found. There must be an easier way dangit...

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

  • Developers

I guess this xml.au3 isn't written by you... right ? believe its written by erifash

So you remove the +1 because it was giving an error ....

And now you are surprised it doesn't work properly anymore...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

yes it was written by erifash.

ok, lets try again...

brain.aiml:

<?xml version="1.0" encoding="ISO-8859-1"?>

<aiml>
    <botinfo>
        <name>MyBot</name>
        <unknown>I'm Sorry. I did not understand what you said. Please try again.</unknown>
    </botinfo>
    
    <category>
        <pattern>hello</pattern>
        <template>Hi there!</template>
    </category>
    
    <category>
        <pattern>What is your name?</pattern>
        <template>I am &botname;. Who are you?</template>
    </category>
</aiml>

Now, Here is the SCiTE console:

>"C:\Program Files\AutoIt3\SciTE\CompileAU3\CompileAU3.exe" /run /beta /ErrorStdOut /in "C:\Documents and Settings\Matt Roth\My Documents\AutoIt\aiml.au3" /autoit3dir "C:\Program Files\AutoIt3\beta" /UserParams  
>Running: (3.1.1.107):C:\Program Files\AutoIt3\beta\autoit3.exe "C:\Documents and Settings\Matt Roth\My Documents\AutoIt\aiml.au3"  
_XMLGet($contents, "botinfo") returned: 

        <name>MyBot</name>

        <unknown>I'm Sorry. I did not understand what you said. Please try again.</unknown>

    

_XMLGet($botinfo, "name") returned: MyBot

_XMLGet($botinfo, "unknown") returned: I'm Sorry. I did not understand what you said. Please try again.

C:\Documents and Settings\Matt Roth\My Documents\AutoIt\aiml.au3 (40) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: 
$patterns[$i] = $cat_pattern 
^ ERROR
>AutoIT3.exe ended.
>Exit code: 0   Time: 2.400

why is it giving me this error? As far as I can see there is the right amount of parts of the array.

MsgBox (0, "info", "found "&$categories_num&" categories.")

that tells me that $categories_num is 2.

So,

Global $patterns[$categories_num]

Global $templates[$categories_num]

that would define $patterns[0-2] and $templates[0-2] right?

For $i=0 To $categories_num

the loop will continue until $i is 2.

$patterns[$i] = $cat_pattern

(that is where the error is)

the highest $i could be is 2, right? so the highest it could get to is $patterns[2] right? and that has been defined as shown abouve. So where is the error coming from?

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

I used the files from up a few posts. Here's what I found:

In the function AIML_Respond, you need two corrections:

Func AIML_Respond ($message)
    [b]$pos = _ArraySearch ($patterns, $message)[/b]
    If $pos = -1 Then
        $response = $unknown_reply
    [b]ElseIf $pos = 0 Then[/b]
        $response = $unknown_reply
    Else
        $response = $templates[$pos]
    EndIf
    Return $response
EndFunc

The bold lines were incorrect in your file.

This section is all messed up:

Global $categories_num = __StringNumOccur ($contents, "<category>")

Global $patterns[$categories_num]
Global $templates[$categories_num]

MsgBox (0, "info", "found "&$categories_num&" categories.")

Global $patterns[$categories_num], $templates[$categories_num]

You don't need to declare the arrays twice. Plus, in order to get rid of the array problem for later, you need to declare the array with $categories_num + 1 instead of simply $categories_num. Fix:

Global $categories_num = __StringNumOccur ($contents, "<category>")

MsgBox (0, "info", "found "&$categories_num&" categories.")

Global $patterns[$categories_num + 1], $templates[$categories_num + 1]

Now you'll be able to access $patterns[2] because the size of the array is 3 (0, 1, 2). You always have to remember that arrays start at 0.

Link to comment
Share on other sites

Thanks greenmacine!

Now this program is making some progres... :lmao:

but, there is still a problem.

even when I enter a message which is in brain.aiml, it says it is not in the templates and defaults out to $unknown_response...

here is what is in the conversation window...

Please type in the input field at the bottom.

---------------

You: hello

MyBot: I'm Sorry. I did not understand what you said. Please try again.

You: What is your name?

MyBot: I'm Sorry. I did not understand what you said. Please try again.

You: blah blah?

MyBot: I'm Sorry. I did not understand what you said. Please try again.

aiml.au3:

XML.au3:

brain.aiml: (it doesnt let me attach it so heres the code):

<?xml version="1.0" encoding="ISO-8859-1"?>

<aiml>
    <botinfo>
        <name>MyBot</name>
        <unknown>I'm Sorry. I did not understand what you said. Please try again.</unknown>
    </botinfo>
    
    <category>
        <pattern>hello</pattern>
        <template>Hi there!</template>
    </category>
    
    <category>
        <pattern>What is your name?</pattern>
        <template>I am &botname;. Who are you?</template>
    </category>
</aiml>

Why doesnt it recognize my responses?

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...