You can find the position of a topic, whether its name is numerical or not by doing a simple loop through $ini. You can then use this position to use $ini(file,position,0) for total items etc.
It returns 0 if the topic was not found, else it returns a positive integer.
/* Usage: $inipos(file,topic)
Returns 0 if the topic doesn't exist
Example: //if ($inipos(test.ini,500)) echo -a $ini(test.ini,$ifmatch,0) items found
*/
Code:
alias inipos {
if (!$isfile($1)) || ($0 < 2) return
if ($2 !isnum) return $ini($1,$2)
var %a = $ini($1,0)
while ($ini($1,%a) != $2) && (%a) dec %a
return %a
}
Here's a little snippet you can try it with:
; Usage: /echoitems <file> <topic>
Code:
alias echoitems {
var %pos = $$inipos($1,$2)
if (%pos == 0) return
var %i = 1, %ii = $ini($1,%pos,0), %item
while (%i <= %ii) {
%item = $ini($1,%pos,%i)
echo -a $+(%item,=,$readini($1,n,$2,%item))
inc %i
}
}