Jump to content

Recommended Posts

Posted

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

CODE

Local $Follows[1000]

$FollowFile = "c:\follows.txt"

_FileReadToArray($FollowFile, $Follows)

$FollowNum = 0

$Follow = $Follows[$FollowNum]

func NextFollow()

$FollowNum = $FollowNum + 1

$PageNum = 1

$follow = $Follows[$FollowNum]

EndFunc

I'm getting this error when my program calls the NextFollow() function and it gets to the 3rd line of the function "$follow = $Follows[$FollowNum]"

Whats going on?

Posted

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

CODE

Local $Follows[1000]

$FollowFile = "c:\follows.txt"

_FileReadToArray($FollowFile, $Follows)

$FollowNum = 0

$Follow = $Follows[$FollowNum]

func NextFollow()

$FollowNum = $FollowNum + 1

$PageNum = 1

$follow = $Follows[$FollowNum]

EndFunc

I'm getting this error when my program calls the NextFollow() function and it gets to the 3rd line of the function "$follow = $Follows[$FollowNum]"

Whats going on?

If $FollowNum > 999 ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.

Posted

If $FollowNum > 999 ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.

But this is happening when FollowNum is at like 2 or 3

Posted

You don't need to declare Follows as an array variable, it'll be an array when returning from _FileReadToArray function. The number of lines, which is also the upper bound of the array is stored into the first subscript. So if $Follows[0] = 50 then the highest valid subscript is $Follows[50].

Posted

You don't need to declare Follows as an array variable, it'll be an array when returning from _FileReadToArray function. The number of lines, which is also the upper bound of the array is stored into the first subscript. So if $Follows[0] = 50 then the highest valid subscript is $Follows[50].

Hmm, I'm not sure I understand.

Basically I have a list of names, 1 per line in a txt file which is being brought into an array

$FollowFile = "c:\follows.txt"

_FileReadToArray($FollowFile, $Follows)

$Follow = $Follows[$FollowNum]

$Follow is the name of the person I want to be using, called by the index $FollowNum which counts up so that after my code has ran, it switches to the next person.

func NextFollow()

$FollowNum = $FollowNum + 1

$follow = $Follows[$FollowNum]

EndFunc

Does that clarify what I'm doing? Or maybe you could rephrase your answer?

Posted (edited)

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

CODE

Local $Follows[1000]

$FollowFile = "c:\follows.txt"

_FileReadToArray($FollowFile, $Follows)

$FollowNum = 0

$Follow = $Follows[$FollowNum]

func NextFollow()

$FollowNum = $FollowNum + 1

$PageNum = 1

$follow = $Follows[$FollowNum]

EndFunc

I'm getting this error when my program calls the NextFollow() function and it gets to the 3rd line of the function "$follow = $Follows[$FollowNum]"

Whats going on?

No idea what you are doing . . . .

Hope this helps

$FollowFile = "c:\follows.txt"
If Not _FileReadToArray($FollowFile, $Follows) Then
MsgBox(4096, "Error", " Error reading " & $FollowFile & " log to Array error:" & @error)
Exit
EndIf


For $i = 0 to UBound($Follows) -1
$Follow = $Follows[$i]
$PageNum = 1
Next

Actually $Follows[0] = the count not the first value, so the $i will need to start at 1 and go to the full without the -1 at the end.

Edited by Hatcheda
Posted

If i remove:

Local $Follows[999]

Then I get the error:

==> Variable used without being declared.:

If Not _FileReadToArray($FollowFile, $Follows) Then

If Not _FileReadToArray($FollowFile, ^ ERROR

Posted (edited)

If i remove:

Local $Follows[999]

Then I get the error:

==> Variable used without being declared.:

If Not _FileReadToArray($FollowFile, $Follows) Then

If Not _FileReadToArray($FollowFile, ^ ERROR

Always a good idea to declare all variables at the top

Dim . . .

Global . . .

Local . . .

Depending on your intended use.

keep the error code around the filereadtoarray . . . . it's good for letting you know what's going on. . . .

Edited by Hatcheda
Posted

Always a good idea to declare all variables at the top

Dim . . .

Global . . .

Local . . .

Depending on your intended use.

keep the error code around the filereadtoarray . . . . it's good for letting you know what's going on. . . .

Thanks everybody, I got it working. There was some other ordering issues that was causing it to not function properly as well, but I couldn't have solved it without your advice! keep up the good work guys ^_^

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