I'm working with ini files in a script for storing info
[info]
1=blabla
2=blabla
7=blabla
12=blabla
now the problem is how to make the bot search trought [info] and output the info of 1,2,7 and 12, one on each line...(those numbers might be different in each section)
when working with inifiles the bot does not read to the end of the file. It read one specified [section] and one [item] under that.
[section]
item=value
so what I want it to do is to read one section multiple times and output the value of the different "items" , one on each lines... like if the items are nicknames...
it would reply : Nick 1(the item) is st00pid(the value of the item)
If you could paste an example of the layout of the INI file (maybe some real data, with many 4 or 5 entries under 3 sections) and how you want the data (from example posted) presented, it will be clearer.
proc read_ini {ini section item} {
set fp [open $ini r]
set insec 0
set ret ""
while {![eof $fp]} {
set in [gets $fp]
if {($insec) || ([string match "[${section}]" $in])} {
set insec 1
if {[string match "[*]" $in]} { break }
if {$item == [lindex [split $in =] 0]} {
set ret [lindex [split $in =] 1]
break
}
}
}
catch {close $fp}
return $ret
}
My Tcl is a little rusty, but this should parse a INI file, and return a item, under a certain section, while ignoring items named the same, under other sections.
already got that
The problem was not the reading part... but how to make one command read through the same section 25 times and output the value of the items, one item on each line in say.. a privmsg
..but as I said.. I used several small procs and that works fine actually. Easier to modify the bot's reply on each item
Thx anyway
_________________
Elen sila lúmenn' omentielvo
<font size=-1>[ This Message was edited by: Papillon on 2002-05-21 09:39 ]</font>