Cod3Monk3y Posted July 21, 2006 Share Posted July 21, 2006 (edited) I have an array that I'm not sure what the finally size will be. As I add items to it, I need to increment the size of it, otherwise it doesn't think the other dimensions exist. I've tried ReDim and that seems to empty the array when it resizes it. Is there a way to ReDim that keeps the current data alone? expandcollapse popupDim $ptrArray[1][2][2] While 1 Select Case $msg = $btnOk If BitAND(GUICtrlRead($cbxP03), $GUI_CHECKED) = $GUI_CHECKED Then If $ptrArray[0][0][0] = "0" Then $ptrArray[0][0][0] = "P03" Else AddToArray("P03") EndIf $aNum = GetArrayCount() - 1 $ptrArray[$aNum][1][0] = "101.79.20.3" $ptrArray[$aNum][0][1] = "lj4050" EndIf If BitAND(GUICtrlRead($cbxP04), $GUI_CHECKED) = $GUI_CHECKED Then If $ptrArray[0][0][0] = "0" Then $ptrArray[0][0][0] = "P04" Else AddToArray("P04") EndIf $aNum = GetArrayCount() - 1 $ptrArray[1][1][0] = "101.79.20.4" $ptrArray[1][0][1] = "lj4250" EndIf Case $msg = $btnCancel Exit EndSelect Wend Func GetArrayCount() Dim $cnt = 0 For $i = 0 To ubound($ptrArray)-1 $cnt = $cnt + 1 Next return $cnt EndFunc Func AddToArray($ptrNum) _ArrayAdd($ptrArray, $ptrNum) EndFunc Edited July 21, 2006 by Cod3Monk3y Link to comment Share on other sites More sharing options...
Squirrely1 Posted July 21, 2006 Share Posted July 21, 2006 It is highly unlikely of course, that there is anything wrong with the ReDim command such that you would have to report a bug the authors over in the Bug Reports forum. The problem has to be in your code. Are you sure that you ReDim'd with the right number of dimension in your array? I noticed you are using a three dimension array. The ReDim statement probably requires the resizing of all three dimensions at once, even if one dimension isn't resized, so that if the original size were [3][2][5] and you want to change to [3][4][5] you should specify all three dimensions. Also, use _ArrayDisplay in a (temporary) error trap in your code to make sure your values aren't there, just not where you expected them to be. I noticed that you are using a loop in this code. Make sure your values were not there during once through the loop, but then died on a subsequent run. Use a trap in the loop and examine there all the values in each dimension. Das Häschen benutzt Radar 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