I was tired of ini files couldnt be searched and came up with an (yet incomplete) however functioning way of searching them
how it works:
it opens the ini on a textfile base ($read)
it scans the file for giving wildcard and returns the line-number
it goes to the line number and moves one line up untill it finds a line starting with "[" (a topic)
it returns that line at the end
disadvantages:
when multiple hits were found, only the first one is shown due to the limits of $read
the script is to slow to integrate in fast scripts, this is why im posting here, anyone got a better solution?
alias sini {
; usage: $sini(inifile, wildcard)
if ($read($1, w, $2-)) {
var %line $readn
while (1) {
dec %line
if ($left($read($1, %line), 1) == $chr(91)) {
var %topic $read($1, %line)
break
}
}
}
return $remove(%topic, $chr(91), $chr(93))
}
the actual purpose of this script is, in my case, this situation:
im creating a linked server in mIRC, who is able to check spamfilter hits and match them to a username/host
the "database" im using is looking like this:
[1]
nick=horstefan
address=stefanpc.lan
spamhits=5
chans=#home,#test,#opers
[2]
etc...
the purpose of the script is to search on: "nick=horstefan" and get the userid (1)
this is (as far as i know) not possible with mirc basic commands...
edit@ napa182:
this script is not meant for searching topics by number, its meant for searching topics by data (like address=stefanpc.lan, or nick=horstefan)
edit@Jethro_:
what exactly is your idea of mimicing... readini doesnt provide this option, so you got any suggestions on it?
ever read the help file?
$ini(file,topic/N,item/N)
Returns the name/Nth position of the specified topic/item in an ini/text file.
$ini(mirc.ini,0) returns total number of topics in mirc.ini
$ini(mirc.ini,1) returns name of 1st topic in mirc.ini
$ini(mirc.ini,help) returns Nth position of topic help if it exists, or returns 0 if it doesn't exist
The item/N parameter is optional. If you specify N = 0, it returns the total number of topics/items.
useing that you can make somthing to search the ini file without making it into txt.