Page 1 of 1 1
Topic Options
#145040 - 2005-08-08 02:54 PM ini files
cbf305 Offline
Fresh Scripter

Registered: 2004-11-02
Posts: 7
Are the ini files that KiXtart reads allowed to have comments? If they are, is there a special character that denotes a comment (i.e. ; # rem)?

Thanks
John

Top
#145041 - 2005-08-08 02:57 PM Re: ini files
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
The semi-colon ";" denotes a commented line in an INI file.
Top
#145042 - 2005-08-08 04:56 PM Re: ini files
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
For example... kix can only read an INI line that has a "item =" on it.

Code:

[section1]
thing1 = some stuff
thing2 = some more stuff
and a return
thing3 = even more stuff

thing4=line1
line2



kix cant read "and a return", the blank line, or the "line2"


Edited by Bryce (2005-08-08 04:59 PM)

Top
#145043 - 2005-08-14 03:59 AM Re: ini files
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
I've used "#" to denote comments in INI files for, well - how old is MS-DOS?

Basically, pretty much anything that doesn't have an "=" sign in it or isn't enclosed in [square brackets] will be ignored. Comments are a matter of convention - since the files are human readable, WE more than the computer need the sameness that the ";" or "#" denotes.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#145044 - 2005-08-14 05:03 AM Re: ini files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
but, what if your comment has equal sign in it?
_________________________
!

download KiXnet

Top
#145045 - 2005-08-14 02:48 PM Re: ini files
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Have you tried to encapsulate .INI values that contain a CRLF, thus wrap onto a second line, into double quotes? This might be a limitation of the underlying API.
_________________________
There are two types of vessels, submarines and targets.

Top
#145046 - 2005-08-14 08:48 PM Re: ini files
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
I know that lines beginning with "#" are ignored per the specification. I regularly include samples of definitions in my INI files that begin with "#", and they are happily ignored by the EnumINI UDFs. Blank lines are ignored as well. Other than Enumeration processes, an INI file will return only what it is asked for, so other things can go unnoticed.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#145047 - 2005-08-14 09:20 PM Re: ini files
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ja, I always viewed commenting an INI file as just another term for "mangling" it - make the line "not normally readable" hence, a comment is born.
Top
#145048 - 2005-08-15 09:31 AM Re: ini files
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
It's a standards thing.

The standard MS definition of of the INI file format states that the comment line starts with a semi-colon - you can find the definition in various resource kits.

As MS regularly break their own standard I wouldn't worry overmuch about it, but if you want to use the correct comment character it is a semi-colon.

Top
#145049 - 2005-08-15 12:56 PM Re: ini files
Lee Wilmott Offline
Starting to like KiXtart

Registered: 2002-09-17
Posts: 106
Loc: Bristol, UK
You are also able to comment entire sections in .INI files by placing a star before the section name...

Code:
*[section1]
thing1 = some stuff
thing2 = some more stuffand a return
thing3 = even more stuff
thing4=line1line2



Lee

Top
#145050 - 2005-08-15 01:13 PM Re: ini files
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

You are also able to comment entire sections in .INI files by placing a star before the section name...

Code:
*[section1]
thing1 = some stuff
thing2 = some more stuffand a return
thing3 = even more stuff
thing4=line1line2



Lee




That's not actually true.

What you are doing is making the section name invalid. If there is a section earlier on in the file then the values will belong to that section.

For example:
Code:

[AAA]
Foo="Section 1"
*[BBB]
Bar="Section 2"



If you ReadProfileString("myini.ini","AAA","Bar") you will get "Section2" returned. Also enumerating section "AAA" will return the values from both sections.

There is no way to comment out a section other than commenting out every line.

You can make it invalid by prefixing it with any character including an asterisk, but whether it will work as you expect will depend upon the application.

Top
#145051 - 2005-08-15 02:49 PM Re: ini files
Lee Wilmott Offline
Starting to like KiXtart

Registered: 2002-09-17
Posts: 106
Loc: Bristol, UK
Richard,

OK, if I'm honest, I've never actually tested it. I just remember reading it 'many' years ago very soon after Windows 3.1 was released!

Lee

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.066 seconds in which 0.028 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