GLBasic User Manual

Main sections

INIOPEN

INIOPEN filename$



Opens an .ini file. If an .ini file has already been opened and altered (INIPUT) when this is called, changes to the previous .ini file will be written to disk before the new file is opened. The .ini files can be any size.
Calling INIOPEN on a .ini file that does not exist will cause it to be created.

An .ini file has the following syntax:
; Comment
[Section1]
Key1 = Value String
Key2 = Value

; Comment
[Section2]
...



Example:
// just to be sure, remove the file
KILLFILE "test.ini"

INIOPEN "test.ini"

color$ = "Colors"
shape$ = "Shapes"

INIPUT color$, "red", 1
INIPUT color$, "green", 2
INIPUT shape$, "Circle", 1
INIPUT shape$, "Poly", "fine"

// write "test.ini" to disk
INIOPEN ""

// Now re-read the file
INIOPEN "test.ini"
PRINT "Red = " + INIGET$(color$, "rEd"), 0, 0
PRINT "Poly = " + INIGET$(shape$, "polY"), 0, 20

PRINT "after removal: ", 0, 50

// remove Color Section
INIPUT color$, "", ""
// remove Poly key
INIPUT shape$, "pOLy", ""

// show again
PRINT "Red = " + INIGET$(color$, "Red"), 0, 70
PRINT "Poly = " + INIGET$(shape$, "PoLy"), 0, 90

SHOWSCREEN
MOUSEWAIT


Output:
Red = 1
Poly = fine

after removal:
Red = NO_DATA
Poly = NO_DATA

See also...