enRAYYY Posted May 13, 2017 Share Posted May 13, 2017 Hi, I have spent the last few hours racking over how to read the keys from a section of an ini file without reading the value fo those keys. Then converting the Keys into a string with a delimiter of "|". Local $aArray = IniReadSection ($SettingsINI, "Users") For $i = 1 To $aArray[0][0] $TECHID = _ArrayToString($aArray[$i][0], "|", -1, -1, " ", -1, - The ini File appears below. [Users] 6335 = 0x037522E59825C11EA7A3A65D32CA525E 1296 = 0xFB9FFE4F3CCF032E8C48468F38766455 1566 = 1 My ideal returned result from this would be: $TECHID = "6335|1296|1566" I have tried the following code to no avail. Any and all help is appreciated, Kind regards enRAYY Link to comment Share on other sites More sharing options...
benners Posted May 13, 2017 Share Posted May 13, 2017 (edited) Something like this? #include <Array.au3> Local $s_TECHID = GetTechID() MsgBox(0,'', $s_TECHID) Func GetTechID() Local $as_IniRead = IniReadSection(@ScriptDir & '\settings.ini', 'Users') If IsArray($as_IniRead) Then Return _ArrayToString($as_IniRead, '|', 1, -1, '|', 0, 0) EndFunc ;==>GetTechID Edited May 13, 2017 by benners shortened Skysnake and Subz 2 Link to comment Share on other sites More sharing options...
enRAYYY Posted May 14, 2017 Author Share Posted May 14, 2017 11 hours ago, benners said: Something like this? #include <Array.au3> Local $s_TECHID = GetTechID() MsgBox(0,'', $s_TECHID) Func GetTechID() Local $as_IniRead = IniReadSection(@ScriptDir & '\settings.ini', 'Users') If IsArray($as_IniRead) Then Return _ArrayToString($as_IniRead, '|', 1, -1, '|', 0, 0) EndFunc ;==>GetTechID Hi Benners, thanks for your quick response, it looks like you understand exactly what I'm after but I've attempted your code aswell as attempting to tweak it, each time it simply returns the variable as 0. I'm assuming the "IF IsArray" is being returned as 0? Link to comment Share on other sites More sharing options...
benners Posted May 14, 2017 Share Posted May 14, 2017 Probably, if $as_IniRead isn't an array, the function will return the normal value which is 0. To check you could try this #include <Array.au3> Local $s_TECHID = GetTechID() MsgBox(0,'', $s_TECHID) Func GetTechID() Local $as_IniRead = IniReadSection(@ScriptDir & '\settings.ini', 'Users') If IsArray($as_IniRead) Then Return _ArrayToString($as_IniRead, '|', 1, -1, '|', 0, 0) Return -1 EndFunc ;==>GetTechID I created an ini from the layout in your first post. I have run the code again and I still get the result you want. The ini is in the same directory as the test script settings.ini Link to comment Share on other sites More sharing options...
enRAYYY Posted May 14, 2017 Author Share Posted May 14, 2017 (edited) 46 minutes ago, benners said: Probably, if $as_IniRead isn't an array, the function will return the normal value which is 0. To check you could try this #include <Array.au3> Local $s_TECHID = GetTechID() MsgBox(0,'', $s_TECHID) Func GetTechID() Local $as_IniRead = IniReadSection(@ScriptDir & '\settings.ini', 'Users') If IsArray($as_IniRead) Then Return _ArrayToString($as_IniRead, '|', 1, -1, '|', 0, 0) Return -1 EndFunc ;==>GetTechID I created an ini from the layout in your first post. I have run the code again and I still get the result you want. The ini is in the same directory as the test script settings.ini Not sure why but that line "return -1" seems to make all the difference for me. Thank you so much for your help. Edited May 14, 2017 by enRAYYY Link to comment Share on other sites More sharing options...
benners Posted May 14, 2017 Share Posted May 14, 2017 No probs, happy to help if I can. The "Return - 1" wouldn't make any difference to the result unless there was a problem reading the section from the ini. If you used the settings.ini I posted that would make the code work. If that's the case I would check the layout of the ini you use in $SettingsINI. Any problems just post. 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