Jump to content
Sign in to follow this  
Gorfy

Problem with Arrays

Recommended Posts

Gorfy

Hey everyone I am new at AutoIt but I am having difficulty with the simplest things. I know three programming languages and can't figure out why this problem has taken up over 15 hours of my time. Could someone please explain to me why the below code gives me the error:

...

Func Parse()
    ReDim $arrayLog
    If $LastLine < _FileCountLines($Log) Then
        $file = FileOpen($Log, 0)
        For $i = $LastLine To _FileCountLines($Log)
            $arrayLog[$i-$LastLine] = String(FileReadLine($file, $i))
            GUICtrlSetData($Label1, $arrayLog[$i-$LastLine])
            GUICtrlSetData($Label2, UBound($arrayLog))
        Next
...

Gives the error ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$arrayLog[$i-$LastLine] = String(FileReadLine($file, $i))

^ ERROR

It works fine when I put $arrayLog[0] though.... which is EXACTLY what $i-$LastLine equals.... help please! And thank you in advance.

Share this post


Link to post
Share on other sites
HopkinsProg

If I'm not mistaken, ReDim requires you to specify a subscript. So, where ReDim $var would not work, ReDim $var[101] would work.

Try changing that line to the following, and see if that helps.

Redim $arrayLog[UBound($arrayLog)+1]

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.