mIRC Home    About    Download    Register    News    Help

Print Thread
#118485 25/04/05 06:56 PM
Joined: Apr 2005
Posts: 53
A
aDevil Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2005
Posts: 53
Somebody can tell me, that why better an ini file than a simple text file? I know in the ini file exist [name] then n0= , n1= , but why is this good?

And sorry for this too much question, I am learning atm.

#118486 25/04/05 07:04 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Not all INI files have "nN=".

When using INI files you write to a [section] with an item and data. We can then call back our data using $readini().

/writeini file.ini Nicks Andy Andy here!

[Nicks]
Andy=Andy here!

We use $readini to read from an INI file at a certain section. To see if an item exists.

//if ($readini(file.ini, Section, Item)) { echo -a exists }

So

//if ($readini(file.ini,Nicks,$me)) { echo -a exists }

-Andy

#118487 25/04/05 07:12 PM
Joined: Apr 2005
Posts: 53
A
aDevil Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2005
Posts: 53
Thanks very much, it will be good in my script. smile

#118488 25/04/05 07:18 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
And, in response to your question about why is it good...

In certain situations, using sections allows you to easily find and control specific information as well as make it easily editable by an end-user. Look in mirc.ini for an example. If someone wants to edit something, it is very easy to find the section to look in and then edit the information. Win.ini or System.ini (Windows startup files) are also very easy to edit because of using the INI format.

Besides making it nice for the end-user (or yourself) for editing, it can also make it easier to structure your saved information to make it much easier to recall information later in a script.

The downside to INI files is the depth limit. You can have a heading, a sub-heading, and data. (also called Section, Name, Data ... or other similar titles, but you get the idea). If you need another level such as:

ReportName
- Chapter 1
-- Part 1
--- Information
-- Part 2
--- Information
- Chapter 2
-- Part 1
--- Information
-- Part 2
--- Information

In this case, you have one sub-level too many and therefore an INI would be not helpful to you. It is really a matter of what you need it for and if anyone will need to edit or find information directly in the file later.


Invision Support
#Invision on irc.irchighway.net
#118489 25/04/05 07:22 PM
Joined: Apr 2005
Posts: 53
A
aDevil Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2005
Posts: 53
Thanks very much, I like this forum, here are very helpfull people. Thanks guys!


Link Copied to Clipboard