GML Functions: INI Files

Introduction
INI is short for initialization. These files are mainly used to store values that you load at the beginning of a program, such as keyboard configurations and settings.

One advantage to using INI files is how simple the format is. They are made up of Sections and Keys.

Here is an example of the contents of an INI file:

[Form] Top=100 Left=100 Caption=The best game ever [Game] MaxScore=12324

The sections in this file are Form and Game. Section names have to have square brackets ( [ ] ) around them.

Keys belong to the section below which they are listed. In the example Top, Left, and Caption are the keys in the Form section, and MaxScore is the only key in the Game section. Directly at the end of the name of the key you must place an equals ( = ) sign and then the value you would like for it.

Section names, key names, and the value of keys can be any combination of upper or lowercase letters, numbers, or characters that Game Maker supports writing in the code editor.

List of GML INI Functions
Click the links for more information and examples on each one.


 * ini_open(name) Opens the INI file with the given name. The ini file must be stored in the same folder as the game!
 * ini_close Closes the currently open INI file.
 * ini_read_string(section,key,default) Reads the string value of the indicated key in the indicated section. When the key or section does not exist the default value is returned.
 * ini_read_real(section,key,default) Reads the real value of the indicated key in the indicated section. When the key or section does not exist the default value is returned.
 * ini_write_string(section,key,value) Writes the string value for the indicated key in the indicated section.
 * ini_write_real(section,key,value) Writes the real value for the indicated key in the indicated section.
 * ini_key_exists(section,key) Returns whether the indicated key exists in the indicated section.
 * ini_section_exists(section) Returns whether the indicated section exists.
 * ini_key_delete(section,key) Deletes the indicated key from the indicated section.
 * ini_section_delete(section) Deletes the indicated section.

INI Tutorials

 * Creating An INI File

Possible Uses

 * Storing settings and options
 * General game information
 * Storing players details
 * Format for a custom saving system

INI Extensions

 * INI DLL
 * Remote INI (Rini)
 * INI Data Structure