Herb191 Posted January 5, 2010 Posted January 5, 2010 Why do I occasionally get this error when I run this: expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $NumberOfadsToRun $Form1 = GUICreate("", 625, 445, 192, 124) $NumberOfadsToRun = 10 RandomlyPickAd() Func RandomlyPickAd() Local $avArray[1] $AdType = "General ad" $avArray[0] = "" ; Looks for all text files in directory $search = FileFindFirstFile("C:\" & $AdType & "\*.txt") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories found") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If $avArray[0] = "" Then $avArray[0] = $file Else _ArrayAdd($avArray, $file) EndIf WEnd ;_ArrayDisplay($avArray) FileClose($search) $OkButton = GUICtrlCreateButton("OK", 512, 408, 81, 25, $WS_GROUP) $Min = 0 $Max = UBound($avArray) While 1 $Random = Random($Min, $Max, 1) If $avArray[$Random] <> "" Then $Combo1 = GUICtrlCreateCombo($avArray[$Random], 152, 168, 129, 19) GUICtrlSetState($Combo1, $GUI_DISABLE) ExitLoop EndIf WEnd If $NumberOfadsToRun < 2 Then $Combo2 = GUICtrlCreateCombo("", 152, 218, 129, 19) Else While 1 $Random = Random($Min, $Max, 1) Select Case $avArray[$Random] = GUICtrlRead($Combo1) Case Else $Combo2 = GUICtrlCreateCombo($avArray[$Random], 152, 218, 129, 19) GUICtrlSetState($Combo2, $GUI_DISABLE) ExitLoop EndSelect WEnd EndIf GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $OkButton EndSelect WEnd EndFunc ;==>RandomlyPickAd The error I get: Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
James Posted January 5, 2010 Posted January 5, 2010 Try replacing Line 48 with: $Max = UBound($avArray) - 1 Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
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