Mbee Posted June 13, 2016 Posted June 13, 2016 (edited) I don't understand why a UBound call isn't working correctly in one specific context (which I'll show below). But here's a test example where it's working perfectly: #include <Array.au3> #include <Constants.au3> #include <StaticConstants.au3> #include <Misc.au3> #include <String.au3> #include <StringConstants.au3> Local $aArray[47][4] Local $iNumRows = UBound($aArray, $UBOUND_ROWS) Local $iNumCols = UBound($aArray, $UBOUND_COLUMNS) Local $iNumDims = UBound($aArray, $UBOUND_DIMENSIONS) Local $iSecondDimSize1 = UBound($aArray, 1) Local $iSecondDimSize2 = UBound($aArray, 2) ; MsgBox($MB_OK, "Array Dims", "$UBOUND_ROWS=" & $iNumRows & ", $UBOUND_COLUMNS=" & $iNumCols & ", $UBOUND_DIMENSIONS=" & $iNumDims & _ ", iSecondDimSize1=" & $iSecondDimSize1 & ", iSecondDimSize2=" & $iSecondDimSize2) Exit The key datum that I need is returned by that final call, UBound($aArray, 2), to get the number of elements in the second dimension. There it works perfectly. But when I try it with a globally declared 2D array, as follows, UBound($aArray, 2) returns the same value as UBound($aArray, 1), which is WAY wrong. Here's the code snippet where it malfunctions: Func _MyAdjustFileInfoAra() Local $Lf_NumRows = UBound($G_FileListInfoAra, $UBOUND_ROWS) Local $Lf_NumCols = UBound($G_FileListInfoAra, $UBOUND_COLUMNS) Local $Lf_2ndDimSize = UBound($G_FileListInfoAra, 2) Where that last call returns a very wrong value. What's going on? Weird, huh? Does it have something to do with the fact that it's global? ETA: (Yes, the global array is already declared and filled before this) Edited June 13, 2016 by Mbee Added comment
BrewManNH Posted June 13, 2016 Posted June 13, 2016 Instead of saying it's already declared, you need to show where it's declared and how. Right now you're asking us to recreate your script to troubleshoot a problem you're having that hasn't been reported previously. Without a working demonstration of the problem no one can diagnose it for you. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Mbee Posted June 13, 2016 Author Posted June 13, 2016 (edited) I apolgize, I didn't realize that was important. Is the following all you need, or should I post more? Global $G_FileListInfoAra[1][4] ; The size of the first dimension is ReDimmed prior to the problem code. Let's say... ReDim G_FileListInfoAra[47][4] Otherwise, there are about 2 thousand lines of code in my app. Surely you don't want me to post it all, correct? Edited June 13, 2016 by Mbee
BrewManNH Posted June 13, 2016 Posted June 13, 2016 Post a reproducer script that demonstrates the issue. I don't need your whole script, just a runnable working script that shows the problem. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
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