#42462 - 2003-07-04 04:09 PM
Re: Creating a blank line between sections in a ini file.
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
If you know definitively which entry in the section will be the last entry, you could...
code:
$nul = WriteProfileString("test.ini","section1", "key", "string"+@CRLF)
|
|
Top
|
|
|
|
#42465 - 2003-07-04 04:34 PM
Re: Creating a blank line between sections in a ini file.
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
You can use the WriteLog2() UDF to build the file you want. You will have to write it one line at a time or build the file by concatenating the text and @CRLF values into a single variable then writing the contents of the variable. [ 04. July 2003, 16:35: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#42466 - 2003-07-04 10:46 PM
Re: Creating a blank line between sections in a ini file.
|
kholm
Korg Regular
   
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
Frans Erich,
You can try this: Function Ini9xStyle() puts in a linefeed before each section, if missing.
code:
$IniFile = '\\Server\Share\IniFile.ini' Ini9xStyle($IniFile) Function Ini9xStyle($IniFile) Dim $PrevLine,$Line,$TmpFile,$FileName If InStr($IniFile,'\') $FileName = SubStr($IniFile,InStrRev($IniFile,'\') + 1) Else $FileName = $IniFile EndIf $TmpFile = %Temp% + '\' + $FileName Del $TmpFile $RC = Open(1,$IniFile) $RC = Open(2,$TmpFile,5) $Line = ReadLine(1) While Not @Error $Line = Trim($Line) If Left($Line,1) = '[' If $PrevLine $RC = WriteLine(2,@CRLF) EndIf EndIf If $Line $RC = WriteLine(2,$Line + @CRLF) EndIf $Line = ReadLine(1) $PrevLine = $Line Loop $RC = Close(1) $RC = Close(2) Copy $TmpFile $IniFile Del $TmpFile EndFunction
Just a remark: If you use KiXtart (or any other tools - like VB - that use the OS dll's to write to ini-files), there wil be no empty lines between the sections if your OS is NT+
To make it 'human readable' you can transform it with: Ini9xStyle()
ps. OS's NT+ can still read it correctly.
-Erik
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 931 anonymous users online.
|
|
|