Jump to content

Recommended Posts

Posted (edited)

I keep getting this error in the log,

C:\Program Files\AutoIt3\Programs\Test2.au3 (26) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

If $What_To_Evaluate = $Array_Of_What_To_Find_Similar[$Step] Then

If $What_To_Evaluate = ^ ERROR

I don't see how this can possibly even happen, can some1 tell me what i'm doing wrong....This script is trying to compare two strings/arrays to find similar words for an AI system I am working on. You can create an Ini file if you want to try and c whats happening for yourself.

Here is the code,

#Include <Array.au3>

$Var = "Thank You"   ;;Test Var
$Similar_Find = Find_Similar($Var)
MsgBox(48, "TestBox", $Similar_Find)


Func Find_Similar($To_Find_Similar)
    $AllKeysAndValues = IniReadSection("C:\InIBrain.ini", "CommunicationSector") ;;Finds all of the the keys and Values
    $Amount_Of_Keys = UBound($AllKeysAndValues) - 1 ;;Finds how many keys are in the sector
    $Amount_Of_Values = UBound($AllKeysAndValues, 2) - 1 ;;Finds how many values are in the sector
    $Array_Of_What_To_Find_Similar = StringSplit($To_Find_Similar, " ") ;;Break down what to find into single words - Should return Who, Made, You?
    For $Step = 0 To $Amount_Of_Keys ;;Start from 0(the first key) down to the The Max(last key)
        For $Jump = 0 To $Amount_Of_Values
            $Evaluate_Result = Evaluate($AllKeysAndValues[$Step][$Jump], $To_Find_Similar) ;;Evaluate the key we are on
            If $Evaluate_Result = "Is Similar"  Then
                Return ($AllKeysAndValues[$Step][$Jump])
            EndIf
        Next
    Next
    MsgBox(48, "TestBox", "No Similarites")
    Return ("No Find")
EndFunc   ;==>Find_Similar

Func Evaluate($What_To_Evaluate, $What_To_Look_For)
    $Array_Of_What_To_Find_Similar = StringSplit($What_To_Look_For, " ") ;;Break down what to find into single words - Should return Who, Made
    $Amount_Of_Words_In_Similarity = UBound($Array_Of_What_To_Find_Similar) - 1 ;;Find how many words we are looking for
    For $Step = 0 To $Amount_Of_Words_In_Similarity ;;Start from 1(the first word) and contine down (to he last word)
            MsgBox(48,"TestBox","Comparing: " & $Array_Of_What_To_Find_Similar[$Step] & @LF & "To: " &$What_to_look_For)
        If $What_To_Evaluate = $Array_Of_What_To_Find_Similar[$Step] Then ;;If there is a matching word then..
            MsgBox(48, "TestBox", "Similarity Found") ;;Tell conciousness that there is a similarity
            Return ("Is Similar") ;;It is similar
        EndIf
    Next
EndFunc   ;==>Evaluate

Thank you ahead of time.

Edit: Updated Code to Most Recent

Edited by ByteMyCookies

My Scripts,[topic="65986"]AI Example[/topic] ,Capable of Emotion!

Posted (edited)

#Include <Array.au3>

$Var = "Who Made you?"  ;;Test Var
$Similar_Find = Find_Similar($Var)
MsgBox(48, "TestBox", $Similar_Find)


Func Find_Similar($To_Find_Similar)
    $AllKeysAndValues = IniReadSection("C:\InIBrain", "CommunicationSector") ;;Finds all of the the keys and Values
    $Amount_Of_Keys = UBound($AllKeysAndValues) -1 ;;Finds how many keys are in the sector
    $Array_Of_What_To_Find_Similar = StringSplit($To_Find_Similar, " ") ;;Break down what to find into single words - Should return Who, Made, You?
    For $Step = 0 To $Amount_Of_Keys ;;Start from 0(the first key) down to the The Max(last key)
        $Evaluate_Result = Evaluate($AllKeysAndValues[$Step][0], $To_Find_Similar) ;;Evaluate the key we are on
        If $Evaluate_Result = "Is Similar"  Then
            Return ($AllKeysAndValues[$Step][0])
        EndIf
    Next
    Return ("No Find")
    MsgBox(48, "TestBox", "No Similarites")
EndFunc   ;==>Find_Similar

Func Evaluate($What_To_Evaluate, $What_To_Look_For)
    $Array_Of_What_To_Find_Similar = StringSplit($What_To_Look_For, " ") ;;Break down what to find into single words - Should return Who, Made
    $Amount_Of_Words_In_Similarity = UBound($Array_Of_What_To_Find_Similar) -1 ;;Find how many words we are looking for
    For $Step = 0 To $Amount_Of_Words_In_Similarity ;;Start from 1(the first word) and contine down (to he last word)
        If $What_To_Evaluate = $Array_Of_What_To_Find_Similar[$Step] Then ;;If there is a matching word then..
            Return ("Is Similar") ;;It is similar
            MsgBox(48, "TestBox", "Similarity Found") ;;Tell conciousness that there is a similarity
        EndIf
    Next
EndFunc   ;==>Evaluate

I'l have a Chocolate-Chip, please

8)

Edited by Valuater

NEWHeader1.png

Posted (edited)

Now it is returning 36...I have no clue y...It should come up as "Who made you?"

UBound is kinda like _ArrayMax right?

Whoops almost forgot ur cookie =)

Edited by ByteMyCookies

My Scripts,[topic="65986"]AI Example[/topic] ,Capable of Emotion!

Posted

IniReadSection()

Success: Returns a 2 dimensional array where element[n][0] is the key and element[n][1] is the value.

ubound(element, 2) returns the size of the "second" demension

your "36" should be a "key" number the way you have this coded

8)

NEWHeader1.png

Posted

You seem to know what u doing, so give me a working func. I want the func to return he Key Name. Not a ""Key" Number".

Sry I sound a lil bossy, just that this func has really been getting in my nails. (Yes funny expression haha plz laugh)

My Scripts,[topic="65986"]AI Example[/topic] ,Capable of Emotion!

  • Moderators
Posted

You seem to know what u doing, so give me a working func. I want the func to return he Key Name. Not a ""Key" Number".

Sry I sound a lil bossy, just that this func has really been getting in my nails. (Yes funny expression haha plz laugh)

Seriously hope you're kidding...

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

I'm not, i seriously need help with this func. normally i can figure out whats wrong but i can't this time. I ripped up the help files and havn't come up with anything.

My Scripts,[topic="65986"]AI Example[/topic] ,Capable of Emotion!

Posted

*********** NOT TESTED

#Include <Array.au3>

$Var = "Who Made you?"   ;;Test Var
$Similar_Find = Find_Similar($Var)
MsgBox(48, "TestBox", $Similar_Find)


Func Find_Similar($To_Find_Similar)
    $AllKeysAndValues = IniReadSection("C:\InIBrain.ini", "CommunicationSector") ;;Finds all of the the keys and Values
    $Amount_Of_Keys = UBound($AllKeysAndValues) - 1 ;;Finds how many keys are in the sector
    $Amount_Of_Values = UBound($AllKeysAndValues, 2) - 1 ;;Finds how many values are in the sector
    $Array_Of_What_To_Find_Similar = StringSplit($To_Find_Similar, " ") ;;Break down what to find into single words - Should return Who, Made, You?
    For $Step = 0 To $Amount_Of_Keys ;;Start from 0(the first key) down to the The Max(last key)
        For $Jump = 0 To $Amount_Of_Values
            $Evaluate_Result = Evaluate($AllKeysAndValues[$Step][$Jump], $To_Find_Similar) ;;Evaluate the key we are on
            If $Evaluate_Result = "Is Similar"  Then
                Return ($AllKeysAndValues[$Step][$Jump])
            EndIf
        Next
    Next
    Return ("No Find")
    MsgBox(48, "TestBox", "No Similarites")
EndFunc   ;==>Find_Similar

Func Evaluate($What_To_Evaluate, $What_To_Look_For)
    $Array_Of_What_To_Find_Similar = StringSplit($What_To_Look_For, " ") ;;Break down what to find into single words - Should return Who, Made
    $Amount_Of_Words_In_Similarity = UBound($Array_Of_What_To_Find_Similar) - 1 ;;Find how many words we are looking for
    For $Step = 0 To $Amount_Of_Words_In_Similarity ;;Start from 1(the first word) and contine down (to he last word)
        If $What_To_Evaluate = $Array_Of_What_To_Find_Similar[$Step] Then ;;If there is a matching word then..
            Return ("Is Similar") ;;It is similar
            MsgBox(48, "TestBox", "Similarity Found") ;;Tell conciousness that there is a similarity
        EndIf
    Next
EndFunc   ;==>Evaluate

8)

NEWHeader1.png

Posted (edited)

Tyvm Valuater, I can figure out why it is only coming up No Find myself. You helped tons =)

You rolled a five, Plz take 5 cookies and advance to next post.

Edited by ByteMyCookies

My Scripts,[topic="65986"]AI Example[/topic] ,Capable of Emotion!

Posted (edited)

Tyvm Valuater, I can figure out why it is only coming up No Find myself. You helped tons =)

Welcome!

8)

Be sure you look at the help file, actually this is a better representation than the code i gave you

$var = IniReadSection("C:\Temp\myfile.ini", "section2")
If @error Then 
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    For $i = 1 To $var[0][0]
        MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])
    Next
EndIf

8)

Edited by Valuater

NEWHeader1.png

Posted

Found a new big problem that i can't figure out, Now its not running my evaluate func. I know this cause I added,

MsgBox(48,"TestBox","Comparing: " & $Array_Of_What_To_Find_Similar[$Step] & @LF & "To: " &$What_to_look_For)

In the For loop of the Evaluate Func and the msgbox's arn't popping up.

My Scripts,[topic="65986"]AI Example[/topic] ,Capable of Emotion!

Posted

Found a new big problem that i can't figure out, Now its not running my evaluate func. I know this cause I added,

MsgBox(48,"TestBox","Comparing: " & $Array_Of_What_To_Find_Similar[$Step] & @LF & "To: " &$What_to_look_For)

In the For loop of the Evaluate Func and the msgbox's arn't popping up.

it wont if you put it here

Return ("Is Similar") ;;It is similar
 MsgBox(48,"TestBox","Comparing: " & $Array_Of_What_To_Find_Similar[$Step] & @LF & "To: " &$What_to_look_For)

thats because it is returning and never gets to the message box

... now your making dingle-berry cookies ehh!!!...???

8)

NEWHeader1.png

Posted

Nice manipulation of my code, you almost got me there! If you look at the first posts code again i updated it, the msgbox is In the start of the For Loop not after the Return (though i do have some other msgboxs after the return statments).

My Scripts,[topic="65986"]AI Example[/topic] ,Capable of Emotion!

Posted

.. If you look at the first posts code again i updated it, the msgbox is In the start of the For Loop not after the Return...

That does not look anything like the code i already gave you

example of your code

For $Step = 0 To $Amount_Of_Keys ;;Start from 0(the first key) down to the The Max(last key)
        $Evaluate_Result = Evaluate($AllKeysAndValues[$Step][0],oÝ÷ ÙìZ^¡ù²r^+ÞÚ2¢æ®¶­sdf÷"b33cµ7FWÒFòb33c´Ö÷VçEôöeô¶W2³µ7F'Bg&öÒFRf'7B¶WF÷vâFòFRFRÖÆ7B¶W¢f÷"b33c´§V×ÒFòb33c´Ö÷VçEôöeõfÇVW0¢b33c´WfÇVFUõ&W7VÇBÒWfÇVFRb33c´ÆÄ¶W4æEfÇVW5²b33cµ7FWÕ²b33c´§V×ÒÂb33cµFõôfæEõ6ÖÆ"

8)

NEWHeader1.png

Posted

No that is still the old code, and it still not working. I thought it was because Inireadsection Returns [n][0] N being the key and 0 being the key name, and [n][1] would return the value of that key of the sector. The code you gave me inc's the second dimention making it [n][3] and on and on. But it isn't even getting to the evaluate func, the code seems to quit right away.

My Scripts,[topic="65986"]AI Example[/topic] ,Capable of Emotion!

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
×
×
  • Create New...