Aeterna Posted April 18, 2009 Share Posted April 18, 2009 ==> 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? Link to comment Share on other sites More sharing options...
Yashied Posted April 18, 2009 Share Posted April 18, 2009 ==> 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. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Aeterna Posted April 18, 2009 Author Share Posted April 18, 2009 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 Link to comment Share on other sites More sharing options...
Authenticity Posted April 18, 2009 Share Posted April 18, 2009 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]. Link to comment Share on other sites More sharing options...
Aeterna Posted April 18, 2009 Author Share Posted April 18, 2009 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? Link to comment Share on other sites More sharing options...
Richard Robertson Posted April 18, 2009 Share Posted April 18, 2009 You need to check to make sure you don't go out of the array. Use UBound($Follows) to get the max that you can go to. Link to comment Share on other sites More sharing options...
John117 Posted April 18, 2009 Share Posted April 18, 2009 (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 April 18, 2009 by Hatcheda Link to comment Share on other sites More sharing options...
Aeterna Posted April 18, 2009 Author Share Posted April 18, 2009 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 Link to comment Share on other sites More sharing options...
Authenticity Posted April 18, 2009 Share Posted April 18, 2009 (edited) Dim $Follows_FileReadToArray("C:\something.txt", $Follows)Edit: Forgive me:Local $Follows_FileReadToArray("C:\something.txt", $Follows);] Edited April 18, 2009 by Authenticity Link to comment Share on other sites More sharing options...
John117 Posted April 18, 2009 Share Posted April 18, 2009 (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 April 18, 2009 by Hatcheda Link to comment Share on other sites More sharing options...
Aeterna Posted April 18, 2009 Author Share Posted April 18, 2009 Always a good idea to declare all variables at the topDim . . .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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now