mIRC Homepage
Posted By: maroon $ini numeric inputs - 25/02/23 02:30 PM
$ini(file.ini,N).name
$ini(file.ini,section,N).name
$ini(file.ini,section,item).value

There currently is no support for locating whether a numeric [section] or numeric item= exists without a bruteforce loop searching for it. While you can try to use $readini(file,section,123) to see if item= named '123' exists, that only works if it has a non-blank value, and does not work with /writeini -z delme.ini section 123

This would make a way for $ini to be compatible with /writeini and $readini who currently handle numeric [section] and item= parameters as if they are literal text strings.

//var %section 3 , %file delme.ini | .remove %file | writeini %file section1 item value1 | writeini %file %section item value2 | echo -a : $qt($ini(%file,%section)) vs $qt($ini(%file,2)) $ini(%file,section1) vs $readini(%file,3,item)

result: : "" vs "3" 1 vs value2

--

Closely related to this, it would be much more streamlined for scripts to be able to use $ini to obtain the item values the same way it gets the item names, without needing an additional disk read to $readini. To avoid ambiguity, unless there are going to be additional propertynames, .value should treat numeric section and item parameters the same Nth-in-list way it currently does when not using any .property.

//var -s %t $ini(mirc.ini,logging) , %i 1 | while (%i <= %t) {
now: echo -a %i: $readini($mircini,nt,logging,$ini($mircini,logging,%i))
new: echo -a %i: $ini($mircini,logging,%i).value
inc %i }

I don't see the need to give $ini the behavior of evaluating %word and $word or handling piped commands in the =value since can use [ ] if needed.

--

The intent of $ini(file.ini,N).name would be to return the Nth position of the numeric item name, the same way that $ini(file.ini,text) does, and that $timer(123).name does.

A design decision would need to be made how to handle $ini(file.ini,12,34).name and $ini(file.ini,12,34).value where it's possible for 2 parameters to be numeric.

Unless there is also a .namevalue property, I believe it would be simplest to have $ini(file.ini,12,34).value behave the same way $ini currently handles numeric inputs without the .value property and treat all numeric inputs as the Nth position, except for returning the value of the 34th item in the 12th section.

For $ini(file.ini,12,34).name it should always return the position for the 34= item if it exists. But a design decision would be needed whether the 12 should always be the Nth section or the name of a section.
© mIRC Discussion Forums