Page 1 of 3 123>
Topic Options
#67008 - 2002-06-14 02:52 PM Comments in an INI file
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Hi,

Somebody want to double-check and/or comment on my response to this guy?

Setting remarks with.

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#67009 - 2002-06-14 03:10 PM Re: Comments in an INI file
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Kent, yeah, imho - your spot on. One could append comments to values using a semi-colon, but one would have to parse the comment back out when reading the line back in. And single-line comments, I imagine, one would need a WRITELINE(). Can't think of a programmatic way to add single-line comments to an INI file. Unless one fudged them with dummy-values that looked like comments (maybe).
Top
#67010 - 2002-06-14 03:26 PM Re: Comments in an INI file
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Kent, your are right on. You will need to use WRITELINE() to add a comment in a .INI file.
_________________________
There are two types of vessels, submarines and targets.

Top
#67011 - 2002-06-14 03:29 PM Re: Comments in an INI file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Shawn,
I believe you're right that there's no API that would insert a comment above a particular line. The only way I can imagine is to Open() it, Readline() each line, parse, and WriteLine() to a new file. One could create a comment= key with WriteProfileString() but its placement within the INI cannot be controlled.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#67012 - 2002-06-14 03:36 PM Re: Comments in an INI file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
one thingie could be used...
as linking two keys together.

let's say key and key_comment
and if wanting numbers:
# and #_comment

then there would be two lines one with comment and one with value.

[ 14 June 2002, 15:37: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#67013 - 2002-06-14 03:38 PM Re: Comments in an INI file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Jooel, [Wink]
Could you elaborate on that. I'm Canadian.

{edit} more like "Huh??"

[ 14 June 2002, 15:44: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#67014 - 2002-06-14 03:41 PM Re: Comments in an INI file
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Good idea, and like Les said, values get written sequentially, and not inserted alphabetically, so one would have to create the comments when the INI file was first generated. Plus the comments would have ugly equal signs in them.

{EDIT}

Jooel, what Les is saying is ... EH ? [Wink]

{EDIT}

LOL

[ 14 June 2002, 15:47: Message edited by: Shawn ]

Top
#67015 - 2002-06-14 03:54 PM Re: Comments in an INI file
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I guess in a perfect world, to implement fancy-schmancy INI comments, it might be wise to do the following:

In script, first check to see if the INI file exists, if no - then use OPEN/WRITELINE/CLOSE to create a "TEMPLATE" INI file, containing a skeleton of all the sections and all single-line comments. The comments would just be declared as strings in the script. Then proceed to poke per usual.

Top
#67016 - 2002-06-14 05:47 PM Re: Comments in an INI file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Shawn,
To poke the comments just above the keys you'd have to WriteLine() both of them or else WriteProfileString() will put the keys at the end of the section.

Guess Jooel must have finally passed out. He was up all last night knocking back brewskies.

BTW, I finally got what Jooel was trying to say. I'm a bit slow on the uptake...

Back to the challenge at hand...
Not an easy task. but do-able. ReadProfileString() the key to a var; remove the key; create a unique comment key; recreate the removed key. They are now sequencial. Parse the file for the comment and rewrite the file(as per my first post) replacing the comment key with the comment line.

If anyone has a better idea...
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#67017 - 2002-06-15 02:11 AM Re: Comments in an INI file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well...
Like I can see, canoucs can understand us finnish even though there is long time needed for the linking and conversion.
but canadian are living in the woods like us and there is cold at winter as is here...

I did not pass out.
I got job assingment from another employer and it was finish at 2am.
so, Im again drinking some beer and starting me weekend relaxation.
and just BTW, probably will go to sleep at tomorrow morning as I have so much to do that can't wait till tomorrow...
_________________________
!

download KiXnet

Top
#67018 - 2002-06-15 02:26 AM Re: Comments in an INI file
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Well Jooel, I having a beer too. [Cool]

Can't quite make out your web page though. After a few more beers it won't really matter. [Big Grin]

[ 15 June 2002, 02:26: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#67019 - 2002-06-15 02:43 AM Re: Comments in an INI file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hoby, what page?
_________________________
!

download KiXnet

Top
#67020 - 2002-06-15 02:45 AM Re: Comments in an INI file
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
http://www.gwspikval.com/jooel/scripts

Wait a minute!!! That's not the same one. [Frown]

[ 15 June 2002, 02:46: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#67021 - 2002-06-15 02:48 AM Re: Comments in an INI file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I know!

changed it just two minutes ago.
that page there was... it was my test page from about 1.5 years ago.

I'm thinking myself as solution provider not the one who makes the solution look nice.
that's why I hate doing webpages...
or any other docs
_________________________
!

download KiXnet

Top
#67022 - 2002-06-15 02:52 AM Re: Comments in an INI file
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Well as solutions go. Any thoughts on "Last Post"

[ 15 June 2002, 02:52: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#67023 - 2002-06-15 03:08 AM Re: Comments in an INI file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
first thing (besides I running in low with my cooler drink...) I want to say:
I don't like perl.
as it's thougth as a standard and everyone uses it...
I'm TCL guy who does even CGI-files with TCL...
syntax not fully flawless exit should be exit 0
thoughts...
nicely modularized...
well.
weird thing is to see your own code there... the kixgolf III code with error checking.

I could use this on my net as don't have wmi...
_________________________
!

download KiXnet

Top
#67024 - 2002-06-15 03:12 AM Re: Comments in an INI file
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I glad I didn't use any Perl then.

I will look for the opportunies to properly use "exit 0". [Wink]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#67025 - 2002-06-15 03:23 AM Re: Comments in an INI file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... I envy you guys. I'm on call this week (and weekend) manning the 24/7 HelpDesk. No brewskies for me this weekend. Well maybe a few as long as I pace myself. Never know when I might have to drive in to the mill and show some idiot how to use a computer. It's amazing how I'm expected to know everything about every application so I can do their work for them. [Confused]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#67026 - 2002-06-15 03:24 AM Re: Comments in an INI file
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Sorry to hear that Les. I'll have another for you. [Big Grin]

[ 15 June 2002, 03:24: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#67027 - 2002-06-15 03:37 AM Re: Comments in an INI file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
How about I just forward the phone to you. [Big Grin]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 3 123>


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

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.074 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

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