Sign in to follow this  
Followers 0
BlueDraGon

Info on INI file structure

7 posts in this topic

I've been using AHK for a bit and wanted to find out how the structure for INI files are done but no one there seemed to know {well, no one there answered my questions about it anyway}.

What I wanted was a way to create a file similar to INI files but structured differently.

Instead of:

[section]

Key=Value

I wanted to make something like:

[section1]

<SubSection1>

Key1=Value

Key2=Value

<SubSection2>

Key1=Value

[section2]

<SubSection1>

...

I know the ini functions here and in AHK cannot do this, but if someone could show me the means they read/write the information maybe I can arrange it to suit what I want. PLEASE????? :P

Thanks a bunch!

Ciao,

Blue Dra'Gon

Share this post


Link to post
Share on other sites



well, not sure if autoit supports this, but i have a workaround.

Make up your own system to check for subs.

do a filereadline and check if the first character is "[", "<", or neither.

based on that would be, is what the line is.


tolle indicium

Share this post


Link to post
Share on other sites

The problem there is, though I'll be able to read the specified lines, I don't see a way to replace a specific line. The FileWrite/FileWriteLine {FileAppend in AHK} both say that they write to the end of a file and that won't help.

The only way I can see past it is to read each line into a variable array - substituting the change in the appropriate place - then delete the file and rewrite it, but that would take processing time, depending on the length of the file. If nothing else I could do it this way, but I'd rather have a faster solution if possible.

Thanks for your reply though!

Ciao,

Blue Dra'Gon

Share this post


Link to post
Share on other sites

Of course you could open one file for input, read a line and parse it, and then write it out to another file, line by line until you have finished processing all of your input file. Basically a loop until EOF inside a file open and file close statement.

This is fundamental programming algorithm - nothing to do with AHK, AutoIt, or any other language. Once you have mastered the concept, coding it any programming language should be fairly straightforward.

Hint: Forget about reading files into arrays - it complicates things too much. Read about case statements in the help file instead.

Share this post


Link to post
Share on other sites

Of course you could open one file for input, read a line and parse it, and then write it out to another file, line by line until you have finished processing all of your input file. Basically a loop until EOF inside a file open and file close statement.

This is fundamental programming algorithm - nothing to do with AHK, AutoIt, or any other language. Once you have mastered the concept, coding it any programming language should be fairly straightforward.

Hint: Forget about reading files into arrays - it complicates things too much. Read about case statements in the help file instead.

Ah, yeah the "Select...Case...EndSelect" would be perfect for a lot of stuff I'm trying out. Except I'm working with AHK currently {might have to switch over to AutoIt, or at least use it for a few things} and they don't have it as far as I can tell. I was thinking of the arrays simply because it would be easy to assign the changes to the correct line number, since the line number will be known, then do a loop to put the whole mess into another file. Anyway, however I accomplish it, it's going to be longer than a simple iniread/iniwrite line would be :P .

Thanks a bunch for the reply!

Ciao,

Blue Dra'Gon

Share this post


Link to post
Share on other sites

This is why we have XML.

Share this post


Link to post
Share on other sites

Of course you could open one file for input, read a line and parse it, and then write it out to another file, line by line until you have finished processing all of your input file. Basically a loop until EOF inside a file open and file close statement.

This is fundamental programming algorithm - nothing to do with AHK, AutoIt, or any other language. Once you have mastered the concept, coding it any programming language should be fairly straightforward.

Hint: Forget about reading files into arrays - it complicates things too much. Read about case statements in the help file instead.

Ah, yeah the "Select...Case...EndSelect" would be perfect for a lot of stuff I'm trying out. Except I'm working with AHK currently {might have to switch over to AutoIt, or at least use it for a few things} and they don't have it as far as I can tell. I was thinking of the arrays simply because it would be easy to assign the changes to the correct line number, since the line number will be known, then do a loop to put the whole mess into another file. Anyway, however I accomplish it, it's going to be longer than a simple iniread/iniwrite line would be :P .

Thanks a bunch for the reply!

Ciao,

Blue Dra'Gon

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0