Euler G. Posted March 12, 2020 Share Posted March 12, 2020 (edited) Folks, I am dealing with an ambiguous behavior of a script that builds a listview from an INI file section. I used the code examples provided by AndrewDaoust and Melba23 on the forum. I use a Windows 7 Ultimate 64-bit laptop where I have both AutoIt3 versions 3.3.14.5 and 3.3.15.0 Beta, all producing the same behavior. I start by getting the INI file section into an array: Global $aArray = IniReadSection($sFilePath, $sSection) After creating the listview I populate it using the following code: 1222 ; Populate listview 1223 Func _Populate_List() 1224 For $i = 1 To $aArray[0][0] 1225 GUICtrlCreateListViewItem($aArray[$i][1], $Listview) 1226 Next 1227 EndFunc ;==>_Populate_List Once populated, the script user can drag and drop listview items to a different position or simply sort them ascending or descending, and of course write the new arrangement back to the INI file section. This works fine on my Windows 7 laptop, but Windows 10 users have report that the drag and drop feature doesn't work as planned. Trying to solve the problem I borrowed a Windows 10 laptop to test the script and it simply didn't work at all! AutoIt (not my code) displays an error message: Quote "Line 1224 (File "E:\Script.exe"): "Error: Subscript used on non-accesible variable." The line 1224 is start of the For/Next loop (see above). Long story short, I have a nicely functional script on Windows 7 (and probably on other Windows previous versions), a partially functional script on some Windows 10 users, and a completely non-functional script on two Windows 10 (a desktop and a laptop) where I had the opportunity to test the script executable. I'm most likely the culprit here so I'm counting on your valuable hints. TIA. Edited March 16, 2020 by Euler G. Best, Euler Link to comment Share on other sites More sharing options...
Developers Jos Posted March 12, 2020 Developers Share Posted March 12, 2020 (edited) Stabs without the script source and more details: Better error checking to ensure the IniReadSection() function actually worked? Better checking whether $aArray exists and is actually an array? Jos Edited March 12, 2020 by Jos seadoggie01 1 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...
Euler G. Posted March 16, 2020 Author Share Posted March 16, 2020 Thanks for your reply, Jos. Yes, both error checking and array existence were handled properly. Unfortunately I can't post the whole code here. Anyway, I found a workaround and this problem was sorted. Instead of using $aArray[0][0] which carries the number of array contents I used UBound($aArray) -1, and that worked fine on Windows 10, though I can't find a reason why it did not in the first construction that sounds more logical to use. Below is how it is now: ; Populate listview Func _Populate_List() ; Enumerate through the array displaying the keys and their respective values. For $i = 1 To UBound($aArray) - 1 GUICtrlCreateListViewItem($aArray[$i][1], $Listview) Next EndFunc ;==>_Populate_List I'm still waiting for an user answer about his particular case where the first code worked partially, and if this new construction solved his problem. The error occurred either when referencing $aArray[0][0] (like in the For...Next loop or on attribution ($nCount = $aArray[0][0]) but only when $aArray[0][0] (a global array) was referenced in a function, not in the main code. Best, Euler Link to comment Share on other sites More sharing options...
Nine Posted March 16, 2020 Share Posted March 16, 2020 You must have modified $aArray[0][0] on the way down. Hard to say but I am pretty sure it is the case...as there is no bug I know on Win10 with this code. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Euler G. Posted March 16, 2020 Author Share Posted March 16, 2020 Nope, no changes at all. All changes are made in the listview and written back to the INI file. Using UBound($aArray) - 1 instead of $aArray[0][0] did the trick for Windows 10. Best, Euler 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