IronFine Posted Thursday at 01:12 PM Posted Thursday at 01:12 PM (edited) The piece of code causes a crash: #include <Array.au3> Dim $array[2][0] _ArrayDisplay($array) with Quote "C:\Program Files (x86)\AutoIt3\Include\ArrayDisplayInternals.au3" (841) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If Not $_g_iTranspose_ArrayDisplay And $_g_aNumericSort_ArrayDisplay[$iCol] Then Other cases are working fine, e.g.: Dim $array[0][0] Dim $array[1][0] Dim $array[0][1] Dim $array[0][2] Dim $array[0][3] Edited Thursday at 06:30 PM by IronFine pixelsearch 1
argumentum Posted Thursday at 02:17 PM Posted Thursday at 02:17 PM (edited) 2 hours ago, IronFine said: Dim $array[2][0] 2 hours ago, IronFine said: Array variable has incorrect number of subscripts I guess I could add a line to prevent code like that, not crash a script. Or I can ignore those that want to make a zero dimension Hey, divide by zero while you're at it Edited Thursday at 03:18 PM by argumentum pixelsearch 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
pixelsearch Posted Thursday at 03:30 PM Posted Thursday at 03:30 PM With an intermediate version of ArrayDisplayInternals, this blocking message was displayed : But I don't use it anymore, sticking to the last official release version. "I think you are searching a bug where there is no bug... don't listen to bad advice."
IronFine Posted Thursday at 04:52 PM Author Posted Thursday at 04:52 PM 2 hours ago, argumentum said: I guess I could add a line to prevent code like that, not crash a script. Or I can ignore those that want to make a zero dimension Hey, divide by zero while you're at it Not gonna do that - just noticied it while debugging and an ReDim operation set the 2nd dimension to zero. Strange that the other case ( Dim $array[0][0] Dim $array[1][0] ) are not causing that problem. Would actually expect the same behaviour in that case.
pixelsearch Posted Thursday at 05:50 PM Posted Thursday at 05:50 PM 56 minutes ago, IronFine said: Strange that the other cases are not causing that problem : Dim $array[0][0] ; no crash Dim $array[1][0] ; no crash Dim $array[2][0] ; crash I guess this is the reason why : Func __ArrayDisplay_SortArrayStruct(Const ByRef $aArray, $iCol) ... For $i = 1 To $_g_nRows_ArrayDisplay - 1 ... If Not $_g_iTranspose_ArrayDisplay And $_g_aNumericSort_ArrayDisplay[$iCol] Then ; crash line ... Next ... EndFunc ;==>__ArrayDisplay_SortArrayStruct The crash line is found inside a For loop * When the number of rows = [0] , the For loop is not executed (For $i = 1 To 0 - 1) ; 1 To -1 * When the number of rows = [1] , the For loop is not executed (For $i = 1 To 1 - 1) ; 1 To 0 * When the number of rows = [2] , the For loop is now executed (For $i = 1 To 2 - 1) ; 1 To 1 Because preparing a sort index on 1 column (to sort the rows) requires at least 2 rows in the array. So all row values > [2] will crash, when the column value is [0] @jpmshould be interested with this thread, he'll decide if it requires a fix or not. "I think you are searching a bug where there is no bug... don't listen to bad advice."
argumentum Posted Thursday at 06:15 PM Posted Thursday at 06:15 PM What do ReDim to less than 1 entry do ?. I guess any script, UDF or not, can be baby-proof. But again, what is the use of declaring an entry of 0 ? @pixelsearch, if you edit __ArrayDisplay_SortArrayStruct(), and @jpm agrees, he'll use your version @IronFine, why do you need to ReDim $aArray[2][0] ? Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
IronFine Posted Thursday at 06:21 PM Author Posted Thursday at 06:21 PM 5 minutes ago, argumentum said: @IronFine, why do you need to ReDim $aArray[2][0] ? I don't need it, like I said just noticied it while debugging and an ReDim operation set the 2nd dimension to zero (zero was the result of calculation).
Solution argumentum Posted Thursday at 06:22 PM Solution Posted Thursday at 06:22 PM Just now, IronFine said: ReDim operation set the 2nd dimension to zero (zero was the result of calculation). ..then, mind the calculation ? 🤷♂️ Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
IronFine Posted Thursday at 06:27 PM Author Posted Thursday at 06:27 PM I already took care of that. Well not the calculation but ensure that the second dimension is not that to zero. I merely wanted to contribute to the community - sorry I offended you. argumentum 1
argumentum Posted Thursday at 06:38 PM Posted Thursday at 06:38 PM 2 minutes ago, IronFine said: sorry I offended you. oh, don't make me get stated with what I take offence of !. 🤬 Actually, am not one to go for "I feel offended", as it does not attend to the matter in question. I don't feel offended. Can, and do, feel perplexed at certain train of thoughts..., but I take no offence. If you were to call me names, then, I'd ask what me being a "insulting word of choice" has to do with what we are discussing. If you feel you offended me then, you are pardoned IronFine 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
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