BlazeLondon Posted March 28, 2006 Share Posted March 28, 2006 1 in 100 times this message throws up, its totally un reproducable which is why i am so stumped.can anyone tell me what it is saying so i can start on the right track to stopping ithttp://www.qualit-uk.com/backup/error.jpg Link to comment Share on other sites More sharing options...
Developers Jos Posted March 28, 2006 Developers Share Posted March 28, 2006 (edited) 1 in 100 times this message throws up, its totally un reproducable which is why i am so stumped. can anyone tell me what it is saying so i can start on the right track to stopping it http://www.qualit-uk.com/backup/error.jpgIt is telling you that $x is greater than the dimension of $InArray. eg Dim $InArray[5] $InArray[5] = "test" This will give an error because $inArray ranges from [0] - [4] which is 5 "sockets" ... To test it you just do : If $x >= Ubound($inarray) -1 then ; problem $x is greater than the array dimension. endif Edited March 28, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
BlazeLondon Posted March 28, 2006 Author Share Posted March 28, 2006 It is telling you that $x is greater than the dimension of $InArray. eg Dim $InArray[5] $InArray[5] = "test" This will give an error because $inArray ranges from [0] - [4] which is 5 "sockets" ... To test it you just do : If $x >= Ubound($inarray) -1 then ; problem $x is greater than the array dimension. endif this is the array, it came from this forum, it removes duplicates from the array just 1 in 100 times it crashes with that message, no reason for it i could at least put in a better error trap i guess rather that it just crashing like msgbox (please try again) where do i put your ubound command to catch the error? Link to comment Share on other sites More sharing options...
Developers Jos Posted March 28, 2006 Developers Share Posted March 28, 2006 this is the array, it came from this forum, it removes duplicates from the arrayjust 1 in 100 times it crashes with that message, no reason for iti could at least put in a better error trap i guess rather that it just crashinglike msgbox (please try again)where do i put your ubound command to catch the error?don't have the script you talk about so don't know.... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
BlazeLondon Posted March 28, 2006 Author Share Posted March 28, 2006 don't have the script you talk about so don't know.... Func Folders ( ) $folders = _ArrayRemoveDupes($folders) EndFunc Func _ArrayRemoveDupes($InArray) Dim $TempArray[$InArray[0]+1][2] $TempArray[0][0] = $InArray[0] For $x = 1 to $InArray[0] $TempArray[$x][0] = $InArray[$x] $TempArray[$x][1] = $x Next $n = $temparray[0][0] $h = 1 While $h <= $n/3 $h = $h * 3 + 1 WEnd While $h >0 For $outer = $h To $n $temp = $temparray[$outer][0] $temp2 = Number(StringStripWS($temparray[$outer][1],1)) $inner = $outer While $inner > ($h - 1) And StringLower($temparray[$inner-$h][0]) >= StringLower($temp) $temparray[$inner][0] = $temparray[$inner-$h][0] $temparray[$inner][1] = $temparray[$inner-$h][1] $inner = $inner - $h WEnd $temparray[$inner][0] = $temp $temparray[$inner][1] = $temp2 Next $h = ($h - 1)/3 WEnd For $blah = 1 To $temparray[0][0]-1 If $TempArray[$blah][0] = $temparray[$blah + 1][0] Then _ArrayDelete($InArray,$temparray[$blah][1]) $InArray[0] = $InArray[0]-1 EndIf Next Return($InArray) EndFunc Func _FileSearch($szMask,$nOption) $szRoot = "" $hFile = 0 $szBuffer = "" $szReturn = "" $szPathList = "*" Dim $aNULL[1] If Not StringInStr($szMask,"\") Then $szRoot = @SCRIPTDIR & "\" Else While StringInStr($szMask,"\") $szRoot = $szRoot & StringLeft($szMask,StringInStr($szMask,"\")) $szMask = StringTrimLeft($szMask,StringInStr($szMask,"\")) Wend EndIf If $nOption = 0 Then _FileSearchUtil($szRoot, $szMask, $szReturn) Else While 1 $hFile = FileFindFirstFile($szRoot & "*.*") If $hFile >= 0 Then $szBuffer = FileFindNextFile($hFile) While Not @ERROR If $szBuffer <> "." And $szBuffer <> ".." And _ StringInStr(FileGetAttrib($szRoot & $szBuffer),"D") Then _ $szPathList = $szPathList & $szRoot & $szBuffer & "*" $szBuffer = FileFindNextFile($hFile) Wend FileClose($hFile) EndIf _FileSearchUtil($szRoot, $szMask, $szReturn) If $szPathList == "*" Then ExitLoop $szPathList = StringTrimLeft($szPathList,1) $szRoot = StringLeft($szPathList,StringInStr($szPathList,"*")-1) & "\" $szPathList = StringTrimLeft($szPathList,StringInStr($szPathList,"*")-1) Wend EndIf If $szReturn = "" Then $aNULL[0] = 0 Return $aNULL Else Return StringSplit(StringTrimRight($szReturn,1),"*") EndIf EndFunc Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN) $hFile = FileFindFirstFile($ROOT & $MASK) If $hFile >= 0 Then $szBuffer = FileFindNextFile($hFile) While Not @ERROR If $szBuffer <> "." And $szBuffer <> ".." Then _ $RETURN = $RETURN & $ROOT & $szBuffer & "*" $szBuffer = FileFindNextFile($hFile) Wend FileClose($hFile) EndIf EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted March 28, 2006 Developers Share Posted March 28, 2006 Think adding this line will ensure that $InArray[0] will never exceed the max entries possible in the array: Func _ArrayRemoveDupes($InArray) If $InArray[0] > UBound($InArray) -1 Then $InArray[0] = UBound($InArray) -1 Dim $TempArray[$InArray[0] + 1][2] SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
BlazeLondon Posted March 28, 2006 Author Share Posted March 28, 2006 Think adding this line will ensure that $InArray[0] will never exceed the max entries possible in the array: Func _ArrayRemoveDupes($InArray) If $InArray[0] > UBound($InArray) -1 Then $InArray[0] = UBound($InArray) -1 Dim $TempArray[$InArray[0] + 1][2]ok thanks ill try that Link to comment Share on other sites More sharing options...
greenmachine Posted March 29, 2006 Share Posted March 29, 2006 Couldn't you just do this? Dim $TempArray[UBound ($InArray)][2] It seems easier since that's what you're doing anyway, and you don't have to change the value of $InArray[0]. Although I guess it should be the number of entries to begin with, at least this way it's guaranteed. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 29, 2006 Developers Share Posted March 29, 2006 Couldn't you just do this? Dim $TempArray[UBound ($InArray)][2] It seems easier since that's what you're doing anyway, and you don't have to change the value of $InArray[0]. Although I guess it should be the number of entries to begin with, at least this way it's guaranteed. The error was on $InArray[$x] so that means to me that sometimes $InArray[0] contains a higher value than Ubound($InArray)-1 for whatever reason .... thats why I proposed the fix to update $InArray[0]..... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
greenmachine Posted March 30, 2006 Share Posted March 30, 2006 The error was on $InArray[$x] so that means to me that sometimes $InArray[0] contains a higher value than Ubound($InArray)-1 for whatever reason .... thats why I proposed the fix to update $InArray[0]..... That is true. I guess I was looking out for the case that the [0] element is actually in use and not just a counter for the number of elements in the 1-x range being used. If you're not allowed to change the [0], just use Ubound all the way through the function. Ubound should never be wrong, as it doesn't depend on something the user put into the array. 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