Return to index

ini functions

map = ini_add_key(ini_map,section_name,key(string),value(any))

top

Add new key-value pair to end of section. Error if key already exists.

Example:

# Example for ini_add_key
write_file("/tmp/za_ini_add.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_add.ini")
ini_add_key(cfg, "section", "newkey", "newval")


map = ini_add_key_with_comment(ini_map,section_name,key(string),value(any),comment(string))

top

Add new key-value pair with inline comment to end of section. Error if key already exists.

Example:

# Example for ini_add_key_with_comment
write_file("/tmp/za_ini_ac.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_ac.ini")
ini_add_key_with_comment(cfg, "section", "newkey", "newval", "comment")


map = ini_delete_key(ini_map,section_name,key(string))

top

Delete key from section. Error if key doesn't exist.

Example:

# Example for ini_delete_key
write_file("/tmp/za_ini_dk.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_dk.ini")
ini_delete_key(cfg, "section", "key")


map = ini_delete_section(ini_map,section_name)

top

Delete section by name and renumber remaining sections.

Example:

# Example for ini_delete_section
write_file("/tmp/za_ini_ds.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_ds.ini")
ini_delete_section(cfg, "section")


array = ini_get_global(ini_map)

top

Get global section entries (before any [section] header).

Example:

# Example for ini_get_global
write_file("/tmp/za_ini.ini", "key=val\n")
cfg = ini_read("/tmp/za_ini.ini")
ini_get_global(cfg)


any = ini_get_key(ini_map,section_name,key(string))

top

Get value of specific key in section. Error if key doesn't exist.

Example:

# Example for ini_get_key
write_file("/tmp/za_ini_gk.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_gk.ini")
ini_get_key(cfg, "section", "key")


array = ini_get_section(ini_map,section_name(string))

top

Get all entries in section including metadata. Error if section doesn't exist.

Example:

# Example for ini_get_section
write_file("/tmp/za_ini_gs.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_gs.ini")
ini_get_section(cfg, "section")


bool = ini_has_key(ini_map,section_name,key(string))

top

Check if key exists in section. Returns true if found, false otherwise.

Example:

# Example for ini_has_key
write_file("/tmp/za_ini_hk.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_hk.ini")
ini_has_key(cfg, "section", "key")


map = ini_insert_section(ini_map,section_name,position)

top

Insert section at position (1-indexed, 0=prepend) and renumber.

Example:

# Example for ini_insert_section
write_file("/tmp/za_ini_is.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_is.ini")
ini_insert_section(cfg, "newsection", 1)


array = ini_list_keys(ini_map,section_name(string))

top

Get array of all key names in section. Error if section doesn't exist.

Example:

# Example for ini_list_keys
write_file("/tmp/za_ini_lk.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_lk.ini")
ini_list_keys(cfg, "section")


map = ini_meta_update(ini_map)

top

Renumber section orders in map to ensure sequential consistency.

Example:

# Example for ini_meta_update
write_file("/tmp/za_ini_mu.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_mu.ini")
ini_meta_update(cfg)


map = ini_new_section(ini_map,section_name)

top

Append new section at end of order and renumber.

Example:

# Example for ini_new_section
write_file("/tmp/za_ini_ns.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_ns.ini")
ini_new_section(cfg, "newsection")


map = ini_read(filepath)

top

Read an INI file and return a map of sections. Empty string key is global section.

Example:

# Example for ini_read
write_file("/tmp/za_test.ini", "[section]\nkey=val\n")
ini_read("/tmp/za_test.ini")


map = ini_set_global(ini_map,entries([]any))

top

Set global section entries.

Example:

# Example for ini_set_global
write_file("/tmp/za_ini.ini", "key=val\n")
cfg = ini_read("/tmp/za_ini.ini")
ini_set_global(cfg, [])


map = ini_set_key(ini_map,section_name,key(string),value(any))

top

Update existing key value. Preserves inline comments. Error if key doesn't exist.

Example:

# Example for ini_set_key
write_file("/tmp/za_ini_sk.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_sk.ini")
ini_set_key(cfg, "section", "key", "newval")


map = ini_set_section(ini_map,section_name(string),entries([]any))

top

Replace entire section with new entries array. Error if section doesn't exist.

Example:

# Example for ini_set_section
write_file("/tmp/za_ini_ss.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_ss.ini")
ini_set_section(cfg, "section", [])


nil = ini_write(ini_map,filepath)

top

Write an INI map to file. Preserves comments and formatting.

Example:

# Example for ini_write
write_file("/tmp/za_ini_w.ini", "[section]\nkey=val\n")
cfg = ini_read("/tmp/za_ini_w.ini")
ini_write(cfg, "/tmp/za_ini_w_out.ini")