INI Files

Edit

General #

With the following commands you can save and load data to .ini files. Unlike with variables and stacks, the data is permanently saved and can be loaded again after you close and reopen SAMMI.

Rules for saving and loading ini files:

  1. Each file needs to have a specific structure for SAMMI to read it, containing [section] and key=”value”.

    Ini file structure
    Ini file structure
  1. You can only save and load .ini files placed in your SAMMI folder or one of its inner folders.
  2. Make sure to use the right command for loading and saving data. There are different commands for text (strings) and different commands for numbers (real values).
  3. Use relative path for loading and reading ini files. I.e. test.ini if you wanna load a file from your SAMMI folder or /image/test.ini if you wanna load one from your SAMMI/image folder.
  4. You do not need to include the extension when loading a file. test is totally acceptable.


Edit

INI: Save Number #

Saves a number to .ini file.

Box Name Type Description
File Name String Name of the file. Will create one if it doesn’t exist. Accepts both relative and absolute path.
Section String The section to save the key under.
Key String Name of the value to be saved.
Number/Variable Value to be saved as the key value.


Edit

INI: Save Text #

Saves text (string) to .ini file.

Box Name Type Description
File Name String Name of the file. Will create one if it doesn’t exist. Accepts both relative and absolute path.
Section String The section to save the key under.
Key String Name of the value to be saved.
Text String Text to be saved as the key value.


Edit

INI: Create Leaderboard #

Generates a leaderboard from a section inside an INI file and saves the result as a string or an array.

Box Name Type Description
File Name File Select Path to the INI file. If the extension is omitted, .ini will be appended.
Section String The INI section to read (e.g., leaderboard).
Format Dropdown / Writable Output line format. Use placeholders {Rank}, {Key}, and {Value}. Several presets are available and the field is writable.
Save Variable As String Variable name to save the result into.
Output As Array Checkbox If checked, the leaderboard is saved as an array (list) instead of a single string.
Sort Ascending Checkbox If checked, entries are sorted ascending; otherwise descending.
Max Number Optional maximum amount of leaderboard entries to return. Leave empty to return all entries.

Behavior:

  • SAMMI reads the specified INI section and builds a list of key/value pairs.
  • Values that parse as numbers are ranked numerically; non-numeric values are ranked lexicographically (case-insensitive).
  • If multiple entries share the same value they share the higher rank. For example, if two entries tie for first place they both receive rank 1; the next entry receives rank 3.
  • If Max is set, only the top amount of entries are returned after sorting and ranking.
  • If Output As Array is enabled the command saves a list of formatted lines; otherwise it saves a single newline-separated string.

Format placeholders:

  • {Rank} - the rank number
  • {Key} - the INI key name
  • {Value} - the value string from the INI

Examples:

Given an INI section [scores] with:

alice=120
bob=95
charlie=120
dave=80
eve=95

With format {Rank}) {Key}: {Value} and Sort Ascending unchecked, the saved string will be:

1) alice: 120
1) charlie: 120
3) bob: 95
3) eve: 95
5) dave: 80

Use the array output mode to get a list you can iterate with Repeat or Array commands.


Edit

INI: Load Number #

Loads a number (real value) from .ini file. Will return 0 if it doesn’t exist.

Box Name Type Description
File Name String Name of the file to load. Accepts both relative and absolute path.
Section String The section to load the key
Key String Name of the key to be loaded
Save Variable As String Variable name you want to save the loaded string under


Edit

INI: Load Text #

Loads text (string) from .ini file. Will return 0 if it doesn’t exist.

Box Name Type Description
File Name String Name of the file to load. Accepts both relative and absolute path.
Section String The section to load the key
Key String Name of the key to be loaded
Save Variable As String Variable name you want to save the loaded string under


Edit

INI: Delete Key #

Deletes a key within the specified section in a .ini file.

Box Name Type Description
File Name String Name of the file. Will create one if it doesn’t exist. Accepts both relative and absolute path.
Section String The section to find the key.
Key String Key to delete.


Edit

INI: Delete Section #

Deletes a whole section of a .ini file, along with all its keys inside of it.

Box Name Type Description
File Name String Name of the file. Will create one if it doesn’t exist. Accepts both relative and absolute path.
Section String The section to delete.


Edit

INI: Key Exists #

Check if a key exists within a given section of a .ini file.
Returns 1 if the key exists and 0 if it does not exist.

Box Name Type Description
File Name String Name of the file. Will create one if it doesn’t exist. Accepts both relative and absolute path.
Section String The section to look inside of.
Key String Name of the key you wish to check.
Save Variable As String Variable to save the result in.


Edit

INI: Section Exists #

Checks if a section exists within the specified .ini file.
Returns 1 if the section exists and 0 if it does not exist.

Box Name Type Description
File Name String Name of the file. Will create one if it doesn’t exist. Accepts both relative and absolute path.
Section String The section to check.
Save Variable As String Variable to save the result in.


Edit

INI: INI to Object #

Converts an INI file into an Object. The Object will have each key as the section name and each value as an object with the keys from the INI file.

Box Name Type Description
Object Name String Object to save the INI content.
File Path String File to save into the object. Accepts both relative and absolute path.
File Object Returned
[names]
follower1="Christinna"
follower2="Roadie"
[Points]
follower1="20.000000"
follower2="12.000000"
       
{
  names: {
    follower1:"Christinna",
    follower2:"Roadie"
  },
  Points: {
    follower1:20,
    follower2:12
  }
}
       


Edit

INI: Object to INI #

Converts a properly formatted Object into an INI file. The Object needs to be a nested object, with each object inside being a section of the INI file.

Box Name Type Description
Object Name String Nested object to convert into the INI file.
File Path String File to save the object content. Accepts both relative and absolute path.
Object File Returned
{
  names: {
    follower1:"Christinna",
    follower2:"Roadie"
  },
  Points: {
    follower1:20,
    follower2:12
  }
}
       
[names]
follower1="Christinna"
follower2="Roadie"
[Points]
follower1="20.000000"
follower2="12.000000"