INI files

To pass certain parameter settings to programs a standard mechanism is the use of INI files. INI files contain sections and each section contains a number of name-value pairs. For example, here is a typical INI file:

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

This file contains two sections, one call Form and the other called Game. The first section contains three pairs. The first two have a real value while the third has a string value. Such INI files are easy to create and change. The following functions exist in Game Maker to read and change the data in them.

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.

 Contributor: Mark Overmars