Jump to content

Problem with Array


Recommended Posts

#include <File.au3>

HotkeySet("!1", "testdb")
while 1
    sleep(100)
wend 
Func testDB()
    $num_id = 12345
    
    $in_filename = "test.csv"
    Dim $lines,$Display, $NumCols
    _FileReadToArray($in_filename, $lines)
    $Columns = StringSplit($lines[1], ",")
    $NumCols=$Columns[0]
    Dim $array[ $lines[0] ][ $Columns[0] ]
    For $i = 1 To $lines[0]
        $Columns = StringSplit($lines[$i], ",")
        If $Columns[0] = 1 Then Continueloop
        For $j = 1 To $Columns[0]
            $array[$i-1][$j-1] = $Columns[$j]
        Next
    Next
    $Rows=$Lines[0]-1
    $p = 1
    while 1
        if $array[$p][0] = $num_id then 
            if $array[$p][2] = "1" then 
                DoIt()              
            else 
                Send("{ESC}")
            endif
            exitloop 
        else
            $p = $p + 1
            ContinueLoop
        endif
    wend
EndFunc

Func DoIt()
    Sleep(2500)
    Send("{F8}")
EndFunc

Why do I keep getting this error?

Array variable has incorrect number of subscripts or subscript dimension range exceeded.: 
if $array[$p][0] = $num_id then 
if ^ ERROR
Edited by ZebrasInBlankets
Link to comment
Share on other sites

Why do I keep getting this error?

Array variable has incorrect number of subscripts or subscript dimension range exceeded.: 
if $array[$p][0] = $num_id then
Because you don't check if $p gets larger than $lines[0], which you used to DIM $array. Print $lines[0] and $p for each iteration of your loop and you'll most probably see that at the end $p becomes $lines[0]+1, which will trigger the error message.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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