AutoHotkey Community

It is currently May 26th, 2012, 6:10 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: ini file comments?
PostPosted: February 7th, 2009, 10:41 am 
Can you place comments in an ini file without disturbing the data?? for example:

blah=1 ;comment here
item=2 ;comment here
blahblah=3 ;comment here


Report this post
Top
  
Reply with quote  
 Post subject: Re: ini file comments?
PostPosted: February 7th, 2009, 11:24 am 
Games wrote:
Can you place comments in an ini file without disturbing the data?

Ask for help


Report this post
Top
  
Reply with quote  
 Post subject: Re: ini file comments?
PostPosted: February 7th, 2009, 11:29 am 
wrong section alert wrote:
Games wrote:
Can you place comments in an ini file without disturbing the data?

Ask for help

oh, crap. Mod, please delete that post (and this one) - I thought I was in scripts and functions. :oops:
I have to go now (and find something to beat my head with).


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2009, 11:54 am 
it depends on what you mean by "without disturbing the data".
The key value (along with the comment) will be assigned to outputvar.
Using your example, Outputvar will contain "blah=1 ;comment here"


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 7th, 2009, 1:48 pm 
Offline

Joined: November 2nd, 2004, 2:43 pm
Posts: 1019
Location: London, UK
wikipedia wrote:
Comments
Semicolons (;) indicate the start of a comment. Comments continue to the end of the line. Everything between the semicolon and the End of Line is ignored.


However my tests show that AHK just copies the whole line ignoring comments. You can easily parse the string retrieved and remove the comments yourself...

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: ini file comments?
PostPosted: May 3rd, 2012, 5:58 am 
Offline
User avatar

Joined: January 1st, 2011, 2:05 pm
Posts: 482
It seems that in AHK you can write comments with a semicolon before or after a Section or Key,
but not on the same line as a Key as it will be added to the value.

To work around this, add the following RegEx line after IniRead:
Code:
IniRead, OutputVar, Filename [, Section, Key, Default]
OutputVar  := RegExReplace( RegExReplace( OutputVar, "^.+\K.(?<=;).+" ), "\s+$" ) ; change OutputVar in orange to desired var name.

_________________
ImageImageImageImage
AHK_L = HUGE BENIFITS!!! FREE :geek: Image and :ugeek: Image!


Last edited by 0x150||ISO on May 3rd, 2012, 7:08 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: ini file comments?
PostPosted: May 3rd, 2012, 6:03 am 
Offline

Joined: June 7th, 2010, 3:40 pm
Posts: 552
If you really need comments in the ini you could use my ini library (see signature) or one of the other ini libraries that support comments.

_________________
(Statistics script) M&K Counter 2.0
My FAST ini Lib
Minecraft NBT Lib


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: batto, BrandonHotkey, hilalpro, just me, Yahoo [Bot] and 65 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group