mIRC Home    About    Download    Register    News    Help

Print Thread
writeini and readini sort #216599
21/11/09 03:46 PM
21/11/09 03:46 PM
Joined: Nov 2009
Posts: 2
K
Kristoffer Offline OP
Bowl of petunias
Kristoffer  Offline OP
Bowl of petunias
K

Joined: Nov 2009
Posts: 2
The <item> option when using writeini should be optional, and when doing so mirc automatically should add n0 n1 etc like in servers.ini. Often I don't want a specific item name.

All the nN should also be sorted automatically when removing and adding items.

The readini must also be modified to get this working. Readini shuld be able to incrementally read items inside a section and work in conjunction with loops. That way you can loop to a specific item you want to delete for example. There is probably a better way to do this. Anyway, it should be able to locate values without their specific itemname.

Re: writeini and readini sort [Re: Kristoffer] #216601
21/11/09 05:37 PM
21/11/09 05:37 PM
Joined: Jul 2006
Posts: 3,515
France
W
Wims Offline
Hoopy frood
Wims  Offline
Hoopy frood
W

Joined: Jul 2006
Posts: 3,515
France
You seem to misunderstand how and in which case a ini file is useful/needed
Quote:
Often I don't want a specific item name
This mean you don't need to store data related together, and that's why you should not use a ini file in this case.
Also, you can make a simple $calc in order to know the item name (n0, n1, etc).

Quote:
All the nN should also be sorted automatically when removing and adding items.
This will break a lot of script, and again, ini file isn't designed to be sorted.

If you want to sort data, use another method of storing, or made your own method to automatically sort ini file


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: writeini and readini sort [Re: Kristoffer] #216607
21/11/09 09:06 PM
21/11/09 09:06 PM
Joined: Oct 2003
Posts: 3,918
Montreal, QC, Canada
A
argv0 Offline
Hoopy frood
argv0  Offline
Hoopy frood
A

Joined: Oct 2003
Posts: 3,918
Montreal, QC, Canada
Why would you locate a value without a specific item name? There's no way for mIRC to know what item you're referring to if you don't tell it..

This isn't even an INI specific issue.. Even when you tell mIRC which token you want from a string via $gettok you have to give it an index. Similarly, when you $read lines from a file in order, you also have to provide line numbers. Otherwise, again, there's no way for mIRC to know.

You might want to use /fopen and $fread, which are stateful file handling operations. $fread does not require specifying a line number for this reason. $readini/$read will never behave this way. /writeini doesn't need to, either, since $readini will not.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: writeini and readini sort [Re: argv0] #216608
21/11/09 10:25 PM
21/11/09 10:25 PM
Joined: Nov 2009
Posts: 2
K
Kristoffer Offline OP
Bowl of petunias
Kristoffer  Offline OP
Bowl of petunias
K

Joined: Nov 2009
Posts: 2
It is just that I have seen servers.ini and also mirc.ini organized this way. I wanted the same kind of thing.

Re: writeini and readini sort [Re: Kristoffer] #216627
23/11/09 03:39 AM
23/11/09 03:39 AM
Joined: Oct 2003
Posts: 3,918
Montreal, QC, Canada
A
argv0 Offline
Hoopy frood
argv0  Offline
Hoopy frood
A

Joined: Oct 2003
Posts: 3,918
Montreal, QC, Canada
You can get the same thing... simply name your items. There's no magic involved in the way mIRC does it internally, the keys are named manually just as you would be expected to do to achieve the same result. More importantly, however, if you don't care about the key names, you probably shouldn't be using ini files.

Note that if you *really* want to iterate through an ini file without the key names, see /help $ini, because it can do that. That would be for reading, not writing, of course.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: writeini and readini sort [Re: Kristoffer] #216649
24/11/09 07:00 AM
24/11/09 07:00 AM
Joined: Jul 2008
Posts: 236
Hell, Australia
S
s00p Offline
Fjord artisan
s00p  Offline
Fjord artisan
S

Joined: Jul 2008
Posts: 236
Hell, Australia
Just because mIRC does it doesn't mean it's a good idea. mIRC has code that dates back to 1996 or something. It'd be a good idea to look at how mIRC's servers.ini would be stored these days, and attempt to mimic that (pretty easy, really) because alot of advances have been made in the years.

I thought I'd never end up saying that.