Jump to content

Need some professional help


Recommended Posts

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!

Link to comment
Share on other sites

#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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

*********** 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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

.. 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

Link to comment
Share on other sites

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!

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...