Difference between revisions of "$readini"

From Scriptwiki
Jump to: navigation, search
 
(mistake in example *hide*)
Line 16: Line 16:
 
  [[while]] (%i <= [[$ini]](mirc.ini,mirc,0)) {
 
  [[while]] (%i <= [[$ini]](mirc.ini,mirc,0)) {
 
   ; echo item's name and value
 
   ; echo item's name and value
   [[echo]] -a $ini(mirc.ini,mirc,%i) => $readini(mirc.ini,mirc,%i)
+
   [[echo]] -a $ini(mirc.ini,mirc,%i) => $readini(mirc.ini,mirc,$ini(mirc.ini,mirc,%i))
 
   ; increase looping-variable by one
 
   ; increase looping-variable by one
 
   [[inc]] %i
 
   [[inc]] %i

Revision as of 15:23, 20 November 2005

Returns a single line of text from an ini file

$readini(filename, [np], section, item)

If the n switch is specified then the line read in will not be evaluated and will be treated as plain text.

If the p switch is specified, command | separators are treated as such instead of as plain text.

Example

echo -a My command prefix is: $readini(mirc.ini,text,commandchar)

This example echo's your command prefix to your active window (usually /).

The following example will loop through all item in mirc.ini in the section called mirc.

var %i = 1
; begin a while-loop through all items in section mirc. $ini(mirc.ini,mirc,0) returns 
; total number of items in this section.
while (%i <= $ini(mirc.ini,mirc,0)) {
 ; echo item's name and value
 echo -a $ini(mirc.ini,mirc,%i) => $readini(mirc.ini,mirc,$ini(mirc.ini,mirc,%i))
 ; increase looping-variable by one
 inc %i
}

See Also

$ini returns the name/Nth position of the specified topic/item in an ini file.

With /writeini you can write to an ini file.