Happy !

TorstenBergmann / INIFile

Project infos

License MIT
Tags
Creation date 2013-05-28
Website

Monticello registration

About INIFile

IMPORTANT

Overview

  • Parser for .INI files (usually used on Windows)
  • can be loaded from ConfigurationBrowser within Pharo

Usage

The project includes a class INIFile that represent an INI file. An INI file is typically stored as a file with an *.ini extension and holds initialization values for an application in the following format:

Examples

Writing to an INI file

|file section stream|
file := INIFile new.
section := file section: 'First section'.
section at: 'key1' put: 'val1'.
section at: 'key2' put: 'val2'.

stream := 'test.ini' asFileReference writeStream.
[file writeOn: stream ] 
    ensure: [ stream close ]

The resulting ini file will be:

[First section]
key1=val1
key2=val2

Reading from an INI File

|file section stream|
stream := 'test.ini' asFileReference readStream.

file := INIFile readFrom: stream.
section := file section: 'First section'.

(section at: 'key1') inspect.

stream close.

Video