setcfg

(setcfg profile_name profile_value)

The setcfg function writes application specific data (parameters) to individual sections of the appdata.ini file.

The appdata.ini file is a general-purpose parameter file located in the system's configuration directory.

Arguments

profile_name

This argument is a string that specifies the section and parameter name. The string must have the following form:

"AppData/[ProfileSection]/[SubSection]/[...]/Parameter"

The use of capitalization within the profile_name string is irrelevant. The maximum length of profile_name is 132 characters.

profile_value

This argument is a string that provides the value of the parameter. The maximum length is 347 characters.

Return Value

If the function has been processed successfully, it returns a string that is equal to profile_value. Otherwise it returns nil.

 Note: If the file appdata.ini does not yet exist in the program's configuration directory, it is created the first time the setcfg is performed.

Examples

The expression

(setcfg "appdata/myapp/par_1" "2.54")

writes the following section and parameter setting to appdata.ini:

[appdata/myapp]

par_1=2.54

The code

(setcfg "appdata/myapp/mysection/par_1" "OFF")

creates or alters the corresponding section and will set or modify the specified parameter setting within appdata.ini:

[appdata/myapp/mysection]

par_1=OFF

The following expression will fail:

(setcfg "test/par1")

Error: Invalid parameter

Related Functions

getcfg, getenv, getvar, setvar, findfile

The getcfg function retrieves application data from the [appdata/...] sections of the appdata.ini file. The appdata.ini file is located in the program's configuration directory. To get the name of the configuration directory, use the getenv function which returns a list including a CADCFG dotted pair list containing the path.