This is a "cheat sheet" for INI file extension by YellowAfterlife.
The extension can be acquired from GM:Marketplace or itch.io.
For questions/support, use forums, or send me an email.
An up-to-date version of this document can always be found online.

Click on sections to expand/collapse them.
Quick display controls: Categories · Sections · Everything ·

INI file management functions

To support having multiple INI files open at once, functions for opening/creating files return a new INI "structure" (technically an array), and other functions take this structure as first argument. This isn't all too different from file_text_ or buffer_ functions.

file_ini_open(path, secure = false)ini

Opens a file by path and returns the INI file.

If the optional secure argument is true, uses the built-in ds_map_secure_* functions to load/save, although this is no longer considered a good measure and you should probably use file_ini_parse with some different method of verifying integrity.

Much like the built-in function, if the path is not valid, assumes the file to be empty.

file_ini_create()ini

Creates a blank INI file.

Note that this will not bind the file to a path, so you will need to use file_ini_bind if you need to save it on disk.

file_ini_parse(string)ini

Parses an INI structure from a string.

This is roughly equivalent to the built-in ini_open_from_string function that was introduced after the extension's release.

Note that this will not bind the file to a path, so you will need to use file_ini_bind if you need to save it on disk.


file_ini_close(ini)

Flushes any unsaved changes to disk and destroys the INI file.

file_ini_destroy(ini)

Destroys an INI file without saving any changes to disk.


file_ini_flush(ini)

Flushes any unsaved changes to disk without destroying the INI file.

This is the preferred method if you use INI for saving player progress - then you will not need to re-open it.

file_ini_print(ini)string

Returns the current state of an INI file as a string - essentially, the same thing that would be written to a file on close/flush.

For files not bound to disk paths, you would use print+destroy to get the changed string and clean up the structure.


file_ini_bind(ini, ?path, secure = false)

Changes what path an INI file is bound to.

If path argument is provided, changes the path that the file will save to via file_ini_flush / file_ini_close, otherwise disables saving to disk.

If the optional secure argument is true, uses the built-in ds_map_secure_* functions to load/save, although this is no longer considered a good measure and you should probably use file_ini_parse with some different method of verifying integrity.

Section functions
file_ini_section_exists(ini, name)bool

Returns whether the given INI structure contains a section of given name.

file_ini_section_delete(ini, name)

Removes a section by the given name from an INI structure.

file_ini_section_names(ini)array<string>

Returns an array of section names of the given INI structure.

Key-value functions
file_ini_read_string(ini, section, key, default:string)string

Equivalent of ini_read_string, but with a file argument in front.

file_ini_read_real(ini, section, key, default:real)real

Equivalent of ini_read_real, but with a file argument in front.

file_ini_read_int(ini, section, key, default:int)int

Basically shorthand for floor(file_ini_read_real(...)).


file_ini_write_string(ini, section, key, value:string)

Equivalent of ini_write_string, but with a file argument in front.

file_ini_write_real(ini, section, key, value:real)

Equivalent of ini_write_real, but with a file argument in front.

file_ini_write_int(ini, section, key, value:int)

Akin to file_ini_write_real but makes sure that the value is integer.


file_ini_key_exists(ini, section, key)bool

Equivalent of ini_key_exists, but with a file argument in front.

file_ini_key_delete(ini, section, key)bool

Equivalent of ini_key_delete, but with a file argument in front.

Returns whether a key-value pair was removed.

file_ini_key_names(ini, section, key)array<string>

Returns an array of key names in the given section.

Configuration functions

These allow to tweak a couple of aspects of how the extension works.

file_ini_opt_quote_keys(?force:bool)bool

Changes whether INI keys should always be quoted.

Off:

[section]
key=1

On:

[section]
"key"=1

If called without an argument, returns the current value.

file_ini_opt_quote_values(?force:bool)bool

Changes whether INI values should always be quoted.

Off:

[section]
key=1

On:

[section]
key="1"

If called without an argument, returns the current value.

file_ini_opt_trailing_comments(?allow:bool)bool

Changes whether comments after INI values are allowed.

Off:

[section]
key=1 ; hello!

On:

[section]
key=1
; hello!

If called without an argument, returns the current value.