FranckGr Posted August 17, 2018 Share Posted August 17, 2018 Hi Seams IniReadSectionNames does not show all Sections names (First one is missing ... [Site Information]) My code Local $aSections=IniReadSectionNames($ThisIni) $ThisIni : [Site Information] Equipment ID:=539456593 Customer Name:=CH Address: =- City State:=Town Country:=France Phone:= Zip Code:=24000 Product Type:=Master[Computer] Computer Name=CHPRODFR Hardware Manufacturer=HP Hardware Model=ProLiant ML350 Gen9 Processor=Intel(R) Xeon(R) CPU E5-2643 v3 @ 3.40GHz Number of memory modules=4 Total Memory size=32 GB BIOS version=P92[Physical Disk Details] 1=2.00 TB[Logical Disk Details] C:\=63.6 GB D:\=2062.1 GB F:\=872.8 GB[NIC Details] Embedded LOM 1 Port 1=00:10:6F:C5:FD:8E Hospital-LAN=70:10:6F:C5:FD:8E[Graphic Card Details] DriverDate=20150826 DriverVersion=4.1.2.2 Name=Matrox G200eh (HP) WDDM 1.2 Status=OK VideoProcessor=Matrox G200eH[Memory Card Details] 8192=752368-081 8192=752368-081 8192=752368-081 8192=752368-081[Missing Components] [Non-standard Components][Installed Hotfixes] $aSections Row|Col 0 [0]|9 [1]|Computer [2]|Physical Disk Details [3]|Logical Disk Details [4]|NIC Details [5]|Graphic Card Details [6]|Memory Card Details [7]|Missing Components [8]|Non-standard Components [9]|Installed Hotfixes Link to comment Share on other sites More sharing options...
BrewManNH Posted August 17, 2018 Share Posted August 17, 2018 Can you please post the INI file you're using? If I make an INI file out of the text you posted, it works fine, so there may be something wrong with your file. 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 Link to comment Share on other sites More sharing options...
user4157124 Posted August 17, 2018 Share Posted August 17, 2018 Possibly contains BOM. Configure editor accordingly (or use $FO_UTF8_NOBOM for FileOpen()) on INI file creation. AUERLO (AutoIt error logger) Link to comment Share on other sites More sharing options...
FranckGr Posted August 17, 2018 Author Share Posted August 17, 2018 Thank you all, you were right, the file was UTF8. I solved it by initializing the file with a @CRLF before the first section. Array is now Row|Col 0 [0]|10 [1]|Site Information [2]|Computer [3]|Physical Disk Details [4]|Logical Disk Details [5]|NIC Details [6]|Graphic Card Details [7]|Memory Card Details [8]|Missing Components [9]|Non-standard Components [10]|Installed Hotfixes Link to comment Share on other sites More sharing options...
FranckGr Posted August 17, 2018 Author Share Posted August 17, 2018 (edited) For those still using INI files. my _IniRead function (Creating default value if it does not exists) Func _IniRead($IniFile, $Section, $Key, $DefaultValue) Local $v = IniRead($IniFile, $Section, $Key, "=====") If $v = "=====" Then If IniWrite($IniFile, $Section, $Key, $DefaultValue) Then $v = IniRead($IniFile, $Section, $Key, "=====") If $v = "=====" Then Return SetError(2,0,$DefaultValue) ; @Error = 2, @Extended = 0 => Should no append (Could create the key, could not read created key) Else Return SetError(0,1,$v) ; @Error = 0, @Extended = 1 => Key was created successfuly in INI file Endif Else Return SetError(1,0,$DefaultValue) ; @Error = 1, @Extended = 0 => Could not create the key, return Default value EndIf Else Return SetError(0,0,$v) ; @Error = 0, @Extended = 0 => Key was existing in INI file EndIf EndFunc Edited August 17, 2018 by FranckGr 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