orbs Posted June 29, 2014 Share Posted June 29, 2014 from the help of IniWriteSection() "If the data is a string, then each key=value pair must be delimited by @LF." here @LF is used to separate key/value pairs. from the example of IniRenameSection() Local $sSection = "Title=AutoIt" & @CRLF & "Version=" & @AutoItVersion & @CRLF & "OS=" & @OSVersion here @CRLF is used to separate key/value pairs. so which is it? i tried and i get that @CRLF is needed, because @LF alone does not pass to next line. so either the help needs correction, or i'm doing something wrong... Link to comment Share on other sites More sharing options...
Solution BrewManNH Posted June 29, 2014 Solution Share Posted June 29, 2014 You can technically use either @LF or @CRLF to end the key/value pairs, the only difference is that if you use @CRLF, as far as I can tell, is that you get an extra blank line in your ini file and it screws up the line endings. I modified the example script from the help file for the IniWriteSection function to use a string instead of an array. I also used both @LF and @CRLF in creating the string.#include <MsgBoxConstants.au3> Example() Func Example() ; Create an INI section structure as an array. The zeroth element is how many items are in the array, in this case 3. Local $aSection = "3=''" & @LF & "Title = AutoIt" & @CRLF & "Version=" & @AutoItVersion & @CRLF & "OS=" & @OSVersion ; Write the array to the section labelled 'General'. IniWriteSection(@TempDir & "\Example.ini", "General", $aSection) ; Read the INI section labelled 'General'. This will return a 2 dimensional array. Local $aArray = IniReadSection(@TempDir & "\Example.ini", "General") ; Check if an error occurred. If Not @error Then ; Enumerate through the array displaying the keys and their respective values. For $i = 1 To $aArray[0][0] MsgBox($MB_SYSTEMMODAL, "", "Key: " & $aArray[$i][0] & @CRLF & "Value: " & $aArray[$i][1]) Next EndIf ; Delete the INI file. FileDelete(@TempDir & "\Example.ini") EndFunc ;==>ExampleThe output to the message boxes are the same with either delimiter, but the result in the INI file is quite different. [General]CRLF3=''CRLFTitle = AutoIt CRCRLFVersion=3.3.12.0 CRCRLFOS=WIN_7 CRCRLFAs you can see by the above, if you use @CRLF, the line strips the LF and leaves the CR, and then adds a blank CRLF line in the ini file. If you use @LF, as in the line that starts with 3, you'll see it behaves normally.So, don't use @CRLF in an ini write section or you'll end up with a non-conventional ini file. Saying this, that means that the example script for IniRenameSection needs to be rewritten to follow the help 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...
orbs Posted June 29, 2014 Author Share Posted June 29, 2014 thank you BrewManNH for the detailed answer, that was very helpful! 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