IronFine Posted February 12 Posted February 12 (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 February 12 by IronFine pixelsearch 1
argumentum Posted February 12 Posted February 12 (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 February 12 by argumentum pixelsearch 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
pixelsearch Posted February 12 Posted February 12 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 February 12 Author Posted February 12 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 February 12 Posted February 12 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 February 12 Posted February 12 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 February 12 Author Posted February 12 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 February 12 Solution Posted February 12 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 February 12 Author Posted February 12 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 February 12 Posted February 12 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