inifile

Top  Previous  Next

inifile

iniobj=new("inifile"[,filename$])

 

This class manages sections and items in a text file in "ini" format, where sections in the file have a [name] header, and items are stored in name=value lines.  The ini file format is common in many applications, including UnForm.  Both the uf90d.ini and ufparam.txt file use this format.

 

If filename$ does not exist and not null, it is interpreted as a string version of INI file content.  It must have headers and name=value pairs under those headers.  You can use \n sequences to represent line feeds, and \\ to represent backslashes.

 

If filename$ is not provided, a temporary file is created that is erased when the object is destroyed.

 

Properties

content$ is the read-only content of the entire file.

filename$ is the read-only name of the file being managed.

 

Methods

getitem$(section$,name$) returns the value of the named line in the named section.

getname$(section$,value$) returns the first name in the section that has the value specified.

getnames$(section$) returns a list of names in a section, delimited by linefeeds ($0A$).

getsection$(section$[,alltext]) returns all lines in the section, delimited by linefeeds ($0A$).  If alltext is supplied and true (non-zero), then all lines, including blank and comment lines, are included.

putitem(section$,name$,value$) replaces or adds a line in the section, in name=value format.

putsection(section$,lines$) replaces or adds an entire section with the contents of lines$, which should be a series of name=value lines separated by linefeeds ($0A$).

removeitem(section$,name$) removes the line identified by name$ from section$

removesection(section$) removes the entire section.