# IupConfigGetVariableStr

Definition: | include pGUI.e string res = IupConfigGetVariableStr(Ihandle config, string group, string key, nullable_string def=NULL) -- or -- string res = IupConfigGetVariableStrId(Ihandle config, string group, string key, integer id, nullable_string def=NULL)
Description: | This function is similar to the IupGetAttribute function, but persistent and optionally with a default. config: Identifier of the configuration database (see IupConfig) group: group name of the variable key: key name of the variable id: used when the variable has a sequential number def: default value of the variable The group and key names should be arbitrarily selected by the programmer to be meaningful and unique across the application, just as you would if you were writing out a .ini file by hand. For example group="MainWindow", key="Font", def="Arial" should result in a config file that contains, amongst other things, "[MainWindow]\nFont=Arial\n". Internally variables are stored as attributes using a "<GROUP>.<KEY>" combination, which is why group and key names cannot contain period ('.') characters. Returns: the variable value or "" if the variable is not set or does not exist. Note that a def value of NULL is automatically converted into "", a string of length 0, and likewise IupConfigSetVariableStr() automatically converts "" into NULL, which prevents a pointless store. Hence should you be testing whether the def value is returned, it may be helpful in some cases to provide "" rather than NULL for that last parameter.
pwa/p2js: | Not supported.
Notes: | The IupConfigGetVariableStr[Id]Def C functions can be replaced with the pGUI functions without the trailing "Def", note however that the default of NULL for the 4th or 5th parameter is (always) returned as "", a string.
Example: |
    Ihandle config = IupConfig()
    IupSetAttribute(config, "APP_NAME", "MyAppName")
    IupConfigLoad(config)
    string font = IupConfigGetVariableStr(config, "MainWindow", "Font", "Arial")
See Also: | IupConfig, IupSetAttribute, IupConfigLoad, IupGetAttribute