Burgaud Posted July 30, 2021 Share Posted July 30, 2021 (edited) This is the script #include <Array.au3> GLOBAL $GROUP = INIReadSection(@ScriptDir & "\config.ini", "GROUP") _ArrayDisplay($GROUP) _ArrayAdd($GROUP, "X|") _ArrayAdd($GROUP, "Y|") _ArrayDisplay($GROUP) config.ini [GROUP] A=x B=x C=x 1st _ArrayDisplay shows $GROUP[0][0] = 3 After ArrayAdd, why 2nd _ArrayDisplay still shows $GROUP[0][0] = 3? Is it because _ArrayAdd threats the array as zero index? Edited July 30, 2021 by Burgaud Link to comment Share on other sites More sharing options...
Solution Subz Posted July 30, 2021 Solution Share Posted July 30, 2021 (edited) You would need to update the first array item using something like: $GROUP[0][0] = Ubound($GROUP) - 1 Or you can use Ubound for looping For $i = 1 To Ubound($GROUP) - 1 ConsoleWrite($GROUP[$i][0] & @CRLF) Next Edited July 30, 2021 by Subz Burgaud 1 Link to comment Share on other sites More sharing options...
ajag Posted July 30, 2021 Share Posted July 30, 2021 (edited) As the help for _ArrayAdd() says: Edited July 30, 2021 by ajag Typo mikell and Subz 2 Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1) Link to comment Share on other sites More sharing options...
mikell Posted July 30, 2021 Share Posted July 30, 2021 Nice remark ajag #include <Array.au3> GLOBAL $GROUP = INIReadSection(@ScriptDir & "\config.ini", "GROUP") _ArrayDisplay($GROUP) $GROUP[0][0] = _ArrayAdd($GROUP, "X|") $GROUP[0][0] = _ArrayAdd($GROUP, "Y|") _ArrayDisplay($GROUP) Subz 1 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