Difference between revisions of "$ini"
From Scriptwiki
m (Fixed bracket miss-match (Missing lower bracket)) |
m |
||
Line 36: | Line 36: | ||
} | } | ||
== See Also == | == See Also == | ||
− | + | * [[$readini]] to see howto read a single line of an ini. | |
− | + | * [[Writeini|/writeini]] to write to an ini file. | |
− | |||
[[Category:File and Directory Identifiers]] | [[Category:File and Directory Identifiers]] | ||
[[Category:Ini]] | [[Category:Ini]] |
Revision as of 09:26, 2 July 2007
Returns the name/Nth position of the specified topic/item in an ini/text file.
$ini(file,topic/N,item/N)
Note that the item/N parameter is optional. If you specify N = 0, it returns the total number of topics/items.
Example
echo -a $ini(mirc.ini,0)
Echos the total number of topics in your mirc.ini.
echo -a $ini(mirc.ini,mirc,0)
Echos the total number of items in the topic mirc in your mirc.ini
The following, more complex example shows howto loop through an entire ini file.
; We want to have an alias called showini. At the end, it will be /showini <inifile> alias showini { ; echos ini name echo -a $1 var %i = 1 ; We begin to loop through all topics. $ini($1,0) returns the total number of topics while(%i <= $ini($1,0)) { ; echos the name of the current topic echo -a - $ini($1,%i) ; set a new looping-variable var %j = 1 ; lets begin to loop through all items in the current topic while (%j <= $ini($1,%i,0)) { ; echo all items in this topic ; $ini($1,%i,%j) returns the item name of the %j's item in the %i's section. ; $ini($1,%i) returns the %i's section name echo -a -- $ini($1,%i,%j) => $readini($1,$ini($1,%i),$ini($1,%i,%j)) ; increase looping variable inc %j } ; increase first looping-variable inc %i } }