19.1 Settings

For certain programmes it is desirable or even necessary to start the programme with tried and tested programme settings each time it is called. The settings mainly refer to

Gambas offers the possibility to store the configuration of a programme in so-called initialisation or configuration files *.conf and to read in and evaluate the contents of this text file at programme start, as an excerpt from a source code shows:

...
PUBLIC SUB SetConfigurationValues()
  cmbRS232PortName.Text = v24Settings["V24Konfiguration/Port-Name", "/dev/ttyS0"]
  cmbSpeed.Text = v24Settings["V24Konfiguration/Geschwindigkeit", "4800"]
  cmbParity.Text = v24Settings["V24Konfiguration/Parität", "NONE"]
  cmbDataBits.Text = v24Settings["V24Konfiguration/AnzahlDatenbits", "8"]
  cmbStopBits.Text = v24Settings["V24Konfiguration/AnzahlStopbits", "1"]
  cmbFlow.Text = v24Settings["V24Konfiguration/Datenflusskontrolle", "NONE"]
END
 
...
 
PUBLIC SUB Form_Close()
  IF RS232.Status = Net.Active THEN CLOSE RS232
  GetConfigurationValues()
  v24Settings["Expander/ExpanderHiddenStatus"] = expRX_TX.Hidden
' V24Settings.Save wird bei Form_Close automatisch ausgelöst
END

Download

Projects

Download