Difference between revisions of "$ini"
From Scriptwiki
m |
m (Missing space between while and ()) |
||
Line 17: | Line 17: | ||
[[var]] %i = 1 | [[var]] %i = 1 | ||
; We begin to loop through all topics. $ini($1,0) returns the total number of topics | ; We begin to loop through all topics. $ini($1,0) returns the total number of topics | ||
− | [[while]](%i <= $ini($1,0)) { | + | [[while]] (%i <= $ini($1,0)) { |
; echos the name of the current topic | ; echos the name of the current topic | ||
echo -a - $ini($1,%i) | echo -a - $ini($1,%i) |
Revision as of 14:36, 2 October 2008
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 } }