|
Joined: Nov 2004
Posts: 822
Hoopy frood
|
OP
Hoopy frood
Joined: Nov 2004
Posts: 822 |
As I tend to script big projects that require a lot of saving to ini files, and since looping through ... 100kb *.inis causes mIRC to freeze for a short period of time, so I thought that mIRC should have a $findline function.
So $findline(users.ini,user3) returns 7 etc.
|
|
|
|
Joined: Nov 2004
Posts: 822
Hoopy frood
|
OP
Hoopy frood
Joined: Nov 2004
Posts: 822 |
Nevermind ... I coded my own
/findline {
window -h @FindLine
loadbuf 0 @FindLine $1
var %line = $fline(@FindLine,* $+ $2- $+ *)
window -c @FindLine
return %line
}
Still .. it would be nice if mIRC had an 'official' one
Last edited by JigsZilla; 27/07/05 06:54 PM.
|
|
|
|
Joined: Oct 2003
Posts: 3,641
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,641 |
what's wrong with $read() and $readn ?
** EDIT with more info **
//var %r = $read(users.ini, w, *user3*) | echo -a $readn
will echo 7
Last edited by argv0; 27/07/05 09:01 PM.
|
|
|
|
Joined: Dec 2002
Posts: 3,534
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,534 |
Why don't you use $read()'s wildcard text and $readn to return the line number that was matched in the previous call to $read().
alias findline {
if ($isfile($1)) {
if ($read($1,w, $+(*,$2-,*))) { return $readn }
}
}
//say $read(readme.txt,Remember to visit) returns 26 if you have mIRC 6.16 readme file still. This could be useful if implemented. Edit: arg0 beat me to it..  -Andy
|
|
|
|
Joined: Dec 2002
Posts: 2,884
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,884 |
If you're having to search through a fair amount of data regularly you'd probably be better off using hash tables instead of an INI file anyway.
|
|
|
|
Joined: Nov 2004
Posts: 822
Hoopy frood
|
OP
Hoopy frood
Joined: Nov 2004
Posts: 822 |
This is my slightly more modififed version
/findline {
window -hk @FindLine
loadbuf 0 @FindLine $1
var %line = $fline(@FindLine,* $+ $2 $+ *,$iif($3 == $null,1,$3))
window -c @FindLine
return $iif(%line == $null,0,%line)
} $findline(mirc.ini,sounds,1) returns 33 $findline(mirc.ini,sounds,2) returns 34 $findline(mirc.ini,sounds,0) returns 6 (how many 'sounds' there are in total) ... just add it to aliases and play around with it yourself. :P
|
|
|
|
Joined: Oct 2003
Posts: 3,641
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,641 |
duhhh were you not paying attention? use $readn
you don't need that bloated beast of an alias
|
|
|
|
Joined: Apr 2003
Posts: 701
Hoopy frood
|
Hoopy frood
Joined: Apr 2003
Posts: 701 |
Line numbers should not matter for ini files, ini files have different sections each with different entries, the location of a section/entry has no effect on it's meaning (well, it shouldn't)
Therefore I see no reason for implementing a strange alias that is against the very foundation of ini files.
And, what should your $findline(file.ini,entry1) return in this case: [section1] entry1=blub entry2=blah
[section2] entry1=maybethis entry2=ploink
[section3] entry1=yesitcangetworse
As for your problem: -> use $read with one of the search switches and $readn -> dump ini files, use a normal text file and use provious option -> dump ini files, use a normal text file and use /fopen and the other commands/identifiers on that help page to write or read the entire ini file in one go -> dump ini files and use a hash table, or several tables if needed <- my suggestion
|
|
|
|
|