logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

inifile - Parsing of Windows INI files

Bugs, Ideas, Feedback

       This document, and the package it describes, will undoubtedly contain bugs and  other  problems.   Please
       report  such  in  the  category  inifile  of  the TcllibTrackers [http://core.tcl.tk/tcllib/reportlist].
       Please also report any ideas for enhancements you may have for either package and/or documentation.

       When proposing code changes, please provide unifieddiffs, i.e the output of diff-u.

       Note further that attachments are strongly preferred over inlined patches. Attachments  can  be  made  by
       going  to the Edit form of the ticket immediately after its creation, and then using the left-most button
       in the secondary navigation bar.

Category

       Text processing

tcllib                                                0.3.3                                        inifile(3tcl)

Description

       This package provides an interface for easy manipulation of Windows INI files.

       ::ini::openfile ?-encodingencoding? ?access?
              Opens  an INI file and returns a handle that is used by other commands.  access is the same as the
              first form (non POSIX) of the open command, with the exception that mode a is not  supported.  The
              default mode is r+.

              The default encoding is the system encoding.

       ::ini::closeini
              Close the specified handle. If any changes were made and not written by commit they are lost.

       ::ini::commitini
              Writes  the file and all changes to disk. The sections are written in arbitrary order. The keys in
              a section are written in alphabetical order. If the ini was opened in read only mode an error will
              be thrown.

       ::ini::revertini
              Rolls all changes made to the inifile object back to the last committed state.

       ::ini::filenameini
              Returns the name of the file the ini object is associated with.

       ::ini::sectionsini
              Returns a list of all the names of the existing sections in the file handle specified.

       ::ini::keysinisection
              Returns a list of all they key names in the section and file specified.

       ::ini::getinisection
              Returns a list of key value pairs that exist in the section and file specified.

       ::ini::existsinisection ?key?
              Returns a boolean value indicating the existance of the  specified  section  as  a  whole  or  the
              specified key within that section.

       ::ini::valueinisectionkey ?default?
              Returns  the  value of the named key and section. If specified, the default value will be returned
              if the key does not exist. If the key does not exist and no default is specified an error will  be
              thrown.

       ::ini::setinisectionkeyvalue
              Sets  the  value of the key in the specified section. If the section does not exist then a new one
              is created.

       ::ini::deleteinisection ?key?
              Removes the key or the entire section and all its keys. A section  is  not  automatically  deleted
              when it has no remaining keys.

       ::ini::commentinisection ?key? ?text?
              Reads  and modifies comments for sections and keys. To write a section comment use an empty string
              for the key. To remove all comments use an empty string for text.  text may consist of a  list  of
              lines  or  one  single  line. Any embedded newlines in text are properly handled.  Comments may be
              written to nonexistant sections or keys and will not return an error. Reading  a  comment  from  a
              nonexistant section or key will return an empty string.

       ::ini::commentchar ?char?
              Reads  and  sets  the  comment  character.  Lines  that  begin  with this character are treated as
              comments. When comments are written out each line is preceded by this character. The default is ;.

Name

       inifile - Parsing of Windows INI files

Synopsis

       package require Tcl8.59

       package require inifile?0.3.3?::ini::openfile ?-encodingencoding? ?access?

       ::ini::closeini::ini::commitini::ini::revertini::ini::filenameini::ini::sectionsini::ini::keysinisection::ini::getinisection::ini::existsinisection ?key?

       ::ini::valueinisectionkey ?default?

       ::ini::setinisectionkeyvalue::ini::deleteinisection ?key?

       ::ini::commentinisection ?key? ?text?

       ::ini::commentchar ?char?

________________________________________________________________________________________________________________

See Also