This shows you the differences between two versions of the page.
— |
gemus_script_reference:functions:set_cfg_item [2020/05/12 11:28] (current) Jimbo created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | Back to [[.:|Script Function Reference]] | ||
+ | ====== Set_CFG_Item() ====== | ||
+ | |||
+ | The Set_CFG_Item() function can be used for manipulating configuration files. You can set single values, or keys and values with a specific delimeter. If you only need to set keys and values (in the form //key=value//), you can use the simpler [[.:set_cfg_value|Set_CFG_Value()]]. If you need to set values in a standard Windows INI file (//[sections]// containing //key=value// pairs), then you should use [[.:set_ini_value|Set_INI_Value()]] instead. | ||
+ | |||
+ | ===== Syntax ===== | ||
+ | |||
+ | <code>Set_CFG_Item(filenum/filename||key||delimiter||value)</code> | ||
+ | |||
+ | ===== Arguments ===== | ||
+ | |||
+ | ^ Argument ^ Required ^ Description ^ | ||
+ | | //filenum/filename// | Yes | The number of the file set in the script's [[..:associated_files|associated files]] list that you want write to, or the absolute path\filename you want to write to. If you are using an absolute path\filename, any [[..:environment_variables|script environment variables]] found in //filename// will be replaced by their actual values when the script is executed. | | ||
+ | | //key// | Yes | The key within the configuration file that you want to set. Any [[..:environment_variables|script environment variables]] found in //key// will be replaced by their actual values when the script is executed. | | ||
+ | | //delimiter// | No | The character or set of characters to use as the delimeter between //key// and //value//. If this parameter is omitted (left blank) then a single space character will be used by default. Any [[..:environment_variables|script environment variables]] found in //delimiter// will be replaced by their actual values when the script is executed. | | ||
+ | | //value// | No | The desired value pertaining to //key// that you want to set. If this parameter is omitted (left blank) then only the //key// will be written to the ini file, without the //delimiter// or //value//. Any [[..:environment_variables|script environment variables]] found in //value// will be replaced by their actual values when the script is executed. | | ||
+ | \\ | ||
+ | |||
+ | ===== Examples ===== | ||
+ | |||
+ | <code> | ||
+ | Set_CFG_Item(%emupath%\config.cfg||MODE||:||Windowed) | ||
+ | </code> | ||
+ | The line in the config file would look something like this: -\\ | ||
+ | MODE:Windowed | ||
+ | |||
+ | <code> | ||
+ | Set_CFG_Item(1||$LOADPATH||%tab%||%gamepath%) | ||
+ | </code> | ||
+ | The line in the config file would look something like this: -\\ | ||
+ | $LOADPATH c:\games | ||
+ | |||
+ | <code> | ||
+ | Set_CFG_Item(2||ControlPort2||||) | ||
+ | </code> | ||
+ | The line in the config file would look something like this: -\\ | ||
+ | ControlPort2 | ||
+ | |||
+ | ===== Remarks ===== | ||
+ | |||
+ | * If the key cannot be found in the specified configuration file it will be created and set to the specified value (if supplied). | ||
+ | * When the script is executed, a warning message will be displayed if the file cannot be found. | ||
+ | |||
+ | ===== See Also ===== | ||
+ | |||
+ | * [[.:set_cfg_value|Set_CFG_Value()]] | ||
+ | * [[.:set_ini_value|Set_INI_Value()]] | ||
+ | * [[.:|Script Function Reference]] |