GLBasic User Manual

Main sections

INIPUT

INIPUT section$, key$, value$



Writes a value to a previously opened .ini file. If you want to remove a key from the file, set the value$="". For removing complete sections, set key$="".

INIPUT "mysection", "mykey", "myvalue" // Add the values to the ini file
INIPUT "mysection", "mykey", "" // remove the value for key mykey from section mysection
INIPUT "mysection", "", "" // remove the section called mysection


See INIOPEN for more details.

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...