inifile(3tcl)

πŸ“¦
version 2.0 Β· 3 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– inifile β€” the manual, but make it cute πŸ’–

okay bestie, welcome to inifile, from the tcllib docs β€” it's the 3tcl manual page, and it's literally all about parsing of Windows INI files. yes THAT kind of file. the little [section] and key = value guys. we're gonna read the whole thing together, no skimming, periodt. ✨


🌸 NAME 🌸

inifile β€” parsing of Windows INI files. that's the whole vibe. πŸ’…


✨ SYNOPSIS ✨

package require Tcl 8.5 9

package require inifile ?0.3.3?

::ini::open file ?-encoding encoding? ?access?

::ini::close ini

::ini::commit ini

::ini::revert ini

::ini::filename ini

::ini::sections ini

::ini::keys ini section

::ini::get ini section

::ini::exists ini section ?key?

::ini::value ini section key ?default?

::ini::set ini section key value

::ini::delete ini section ?key?

::ini::comment ini section ?key? ?text?

::ini::commentchar ?char?

look at that lineup. it's giving iconic, it's giving organized, it's giving "I know exactly what I'm doing." πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so this package hands you an interface for easy manipulation of Windows INI files. easy being the key word, bestie. no cap. πŸ’œ

the commands, one by one, no skipping 🫢

  • ::ini::open file ?-encoding encoding? ?access? β€” opens an INI file and gives you back a handle that all the other commands use. the access argument works the same as the first form (the non POSIX one) of the open command β€” except that mode a is not supported. the default mode is r+. the default encoding is the system encoding. 🌈
  • ::ini::close ini β€” closes the handle you specified. ⚠️ heads up: if any changes were made and they weren't written out by commit, they are lost. gone. bye. 😭
  • ::ini::commit ini β€” writes the file and all the changes to disk. here's the tea though: the sections get written in arbitrary order, and the keys inside a section get written in alphabetical order. also, if the ini was opened in read only mode, an error will be thrown. πŸ’€
  • ::ini::revert ini β€” rolls all the changes made to the inifile object back to the last committed state. undo button energy. 🧚
  • ::ini::filename ini β€” returns the name of the file that the ini object is associated with. simple. slay. πŸ’…
  • ::ini::sections ini β€” returns a list of all the names of the existing sections in the file handle you specified. ✨
  • ::ini::keys ini section β€” returns a list of all the key names in the section and file you specified. πŸ”‘
  • ::ini::get ini section β€” returns a list of key value pairs that exist in the section and file you specified. πŸŽ€
  • ::ini::exists ini section ?key? β€” returns a boolean value telling you whether the section as a whole exists, or whether the specific key inside that section exists. yes/no, bestie, that's it. βœ…
  • ::ini::value ini section key ?default? β€” returns the value of the named key and section. if you passed a default, that default gets returned when the key doesn't exist. but if the key doesn't exist and you gave no default, an error will be thrown. πŸ™ˆ
  • ::ini::set ini section key value β€” sets the value of the key in the section you named. if the section doesn't exist yet, a new one gets created. main character energy fr fr. πŸ‘‘
  • ::ini::delete ini section ?key? β€” removes the key, or the entire section and all its keys. important note: a section is not automatically deleted just because it has no keys left in it. it just sits there. empty. vibing. πŸ“
  • ::ini::comment ini section ?key? ?text? β€” reads and modifies comments for sections and keys. want to write a section comment? use an empty string for the key. want to remove all the comments? use an empty string for text. text can be a list of lines or one single line, and any embedded newlines in text get properly handled. also β€” and this is the good part β€” comments may be written to nonexistant sections or keys and it will not return an error. and reading a comment from a nonexistant section or key just returns an empty string. chill behavior honestly. 🌸
  • ::ini::commentchar ?char? β€” reads and sets the comment character. any line that begins with this character is treated as a comment, and when comments get written out, every line is preceded by this character. the default is ;. 😌

😭 BUGS, IDEAS, FEEDBACK 😭

ngl, this document and the package it describes will undoubtedly contain bugs and other problems. it's giving humbling. please report those in the category inifile of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist. and please also report any ideas for enhancements you may have for either the package and/or the documentation. we want the glow up. ✨

when you're proposing code changes, please provide unified diffs, i.e. the output of diff -u. 🫢

also note further that attachments are strongly preferred over inlined patches. you can make an attachment 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. iykyk. πŸ’…


πŸŽ€ CATEGORY πŸŽ€

Text processing πŸ’–


and that's the whole page, bestie. this one came from tcllib, version 0.3.3, and it's the inifile(3tcl) manual page β€” so now you know your INI files inside and out. go forth and parse. periodt. πŸ’œπŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from