Page 1 of 1 1
Topic Options
#42460 - 2003-07-04 02:14 PM Creating a blank line between sections in a ini file.
Grutte Pier Offline
Getting the hang of it

Registered: 2001-10-06
Posts: 52
Loc: Leeuwarden, The Netherlands
Can someone please explane how I create blanklines between two sections in a ini file.
The sections are created by my script.

Thanks,

Frans Erich

Top
#42461 - 2003-07-04 02:17 PM Re: Creating a blank line between sections in a ini file.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
there is no blank lines in ini [Big Grin]
you can tweak the ini by writing blank lines later with writeline()
_________________________
!

download KiXnet

Top
#42462 - 2003-07-04 04:09 PM Re: Creating a blank line between sections in a ini file.
Chris S. Offline
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
#42463 - 2003-07-04 04:11 PM Re: Creating a blank line between sections in a ini file.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
INI files are meant for computers to read, not humans. Computers don't care about blank lines, why should you?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#42464 - 2003-07-04 04:21 PM Re: Creating a blank line between sections in a ini file.
Grutte Pier Offline
Getting the hang of it

Registered: 2001-10-06
Posts: 52
Loc: Leeuwarden, The Netherlands
The files I need this sollution for are AXT files. Those are used to distribute software in an Novell exnviorment. The files have the same setup as ini files but in this case the blank lines are eccential.

Thanks Chris S. For a working sollution.

Happy scripting

Top
#42465 - 2003-07-04 04:34 PM Re: Creating a blank line between sections in a ini file.
Howard Bullock Offline
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#42466 - 2003-07-04 10:46 PM Re: Creating a blank line between sections in a ini file.
kholm Offline
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
#42467 - 2003-07-07 03:01 PM Re: Creating a blank line between sections in a ini file.
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
However, if you insert blank lines into the .INI file then the SPLIT function after a READPROFILESTRING where you read all sections or keys will also create a blank array element as last element as the CHR(10) character is used as a delimiter. Thus it is better to not insert the blank lines or one has to check for blank array elements after SPLITting a READPROFILESTRING. Personally, I always check for blanks anyway.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1821 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.069 seconds in which 0.036 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org