The AddIniAny method is used to write, change and read integer variable from the ini file. Unlike the AddIni method, in the AddIniAny method you can specify the section of the file that contains the integer variable. The method returns the value of the variable after its changing.
Syntax for method invocation:
function AddIniAny(varName: String, varValue: int, path: String, section: String): int
- varName is a required argument. It specifies the name of the variable in the file.
- varValue is a required argument. It specifies the value of the variable or a value which must be added to the existing value of variable:
- The varValue value will be assigned to the variable if there is a variable with the varName name and a string value in the file.
- If there is no variable with the varName name in the file, such a variable will be created and the varValue value will be assigned to it.
- If there is a variable with the varName name in the file and it has an integer value or its value can be brought to the integer type, the value will be brought to the integer type and the varValue value will be added to it..
- path is a required argument. It specifies the full path to the ini file in which the variable must be stored. Storage of variables can be placed on the network resource. To do this, enter the network path in the argument.
- section is a required argument. It specifies the name of the section of the ini file in which the variable is stored.
Example. There is no MyVar variable in the config section of the C:\\test.ini file. Write to this file such a variable with the -1 value, then add 1 to it and display the result value in the script debug window.
var result = AddIniAny("MyVar", -1, "C:\\test.ini", "config");
result = AddIniAny("MyVar", 1, "C:\\test.ini", "config");
DebugLogString(result);