settings init - part-cw/lambdanative GitHub Wiki
(settings-init defaults)
settings-init initializes settings table with default setting values (found in defaults which is list of lists) and then overrides these with any settings found in config/settings.scm. The defaults list can be empty if all required settings are already stored in a file, but generally no settings file will exist when the app is first built.
Parameter | Description |
---|---|
defaults | A list of key:value pairs created with cons. E.g. (list (cons "key "value")) |
Example
Example 1: Initialize the settings file and retrieve and store some settings values
;; Make sure we have a config directory
(let ((configdirectory (string-append (system-directory) (system-pathseparator) "config")))
(if (not (file-exists? configdirectory))
(create-directory configdirectory)))
;; Initialize the settings file
(settings-init (list (cons "Localization" 1)
(cons "SensorLocations" (list "Ear" "Hand" "Foot"))))
;; Retrieve and store some settings values
(display (settings-ref "Localization")) (newline)
(define username "demo")
(if (string? username) (settings-set! "Username" username))