19.1.1 Settings - configuration files

The default for configuration files is defined by freedesktop.org like this: A configuration file <application-name>.<extension> is stored in the ~/.config/ directory. The extension of the configuration file is freely selectable. Recommended is 'conf'. Gambas3 adheres to this standard with the Settings class and with its own configuration files.

In the default setting of the Settings component used, the configuration file is a simple text file *.conf and can be edited subsequently with a text editor, for example to insert comments. This is possible because the path of a configuration file allows reading and writing by the logged-in user:

User.Home &/ ".config/gambas3" &/ Application.Name & ".conf"

The following notes for the content of a configuration file should be observed:

[Expander]
ExpanderHiddenStatus=False

[V24Konfiguration]
Port-Name="ttyUSB0"
Geschwindigkeit="9600"
Parität="NONE"
...
Datenflusskontrolle="NONE"
<LEERZEILE>

The configuration data in the configuration file is accessed at programme runtime using the section name/key combination or at programme startup if the key-value pair does not exist, as shown in the following excerpt from the source code for the Temperature Measurement project in the Form_Open() event:

Syntax:    Wert = Setting-Objektname["Sektionsbezeichner/Schlüsselname", optional "Vorgabewert"]

expRX_TX.Hidden = v24Settings["Expander/ExpanderHiddenStatus", TRUE]    	---> 	False
cmbSpeed.Text   = v24Settings["V24Konfiguration/Geschwindigkeit", "4800"]	---> 	9600
cmbParity.Text  = v24Settings["V24Konfiguration/Parität", "NONE"]		--->	NONE

In the following sections, projects are presented in which.

The following priorities are set for all the projects presented:

To manage the configuration of the application, you must include the gb.settings component in your project.

Download