User Tools

Site Tools


19.1.1 Settings - configuration files

The default for configuration files is defined by 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:

  • An empty line is ignored.
  • A comment begins with the # character or a semicolon and is ignored.
  • The identifier for a section (slot) - which may only occur once in the configuration file - is enclosed in square brackets.
  • Under the section identifier [identifier ], there are key-value pairs in further lines. The separator between the key and the value is an equal sign. The value after the equal sign is of type string and is therefore enclosed by “…”.
  • Sections are terminated with a blank line; it separates sections from each other.


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 default path for a configuration file is used or.
  • the configuration file is stored in a directory created by the user, or
  • profiles are used, as they are necessary, for example, for an FTP programme with different FTP accounts.

The following priorities are set for all the projects presented:

  • Creating the configuration file,
  • provision of default values at the first programme start, since in this case no configuration file exists yet,
  • creating sections and setting the associated key-value pairs,
  • reading key-value pairs and assigning the values (component properties and variables),
  • changing key-value pairs within a section, and
  • deleting sections with all key-value pairs; only in the project with profiles.

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


The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k19/k19.1/k19.1.1/start.txt · Last modified: 13.10.2023 by emma

Page Tools