`settings` is a built-in global object for reading and writing host application settings.
It is used directly by name. Do not call `settings()`.
`settings` is a predefined global object. It is not created with a constructor.
| Item | Description |
|---|---|
| Syntax | `settings` |
| Arguments | not applicable |
| Returns | settings object |
print(settings.exists('displayX'));
Known settings can be read as properties.
Property names are host setting names. If the setting does not exist, property access raises an error.
x = settings.displayX;
Use `exists(name)` before reading optional settings or settings that may depend on host version.
if (settings.exists('displayX')) { x = settings.displayX; }
Returns a display string for the object.
| Item | Description |
|---|---|
| Syntax | `value.to_string()` |
| Arguments | none |
| Returns | string |
Example:
text = value.to_string();
`clone()` is not supported for `settings`.
Returns `true` if a setting with `name` exists.
| Item | Description |
|---|---|
| Syntax | `settings.exists(name)` |
| Arguments | `name`: setting name |
| Returns | boolean |
if (settings.exists('displayX')) { print('setting exists'); }
Returns the setting value.
If the setting does not exist, an error is raised.
| Item | Description |
|---|---|
| Syntax | `settings.get(name)` |
| Arguments | `name`: setting name |
| Returns | setting value |
x = settings.get('displayX');
Sets a setting value and returns an OK result.
If the setting does not exist or the value is invalid for that setting, an error is raised.
| Item | Description |
|---|---|
| Syntax | `settings.set(name, value)` |
| Arguments | `name`: setting name; `value`: new setting value |
| Returns | OK result |
settings.set('displayX', 100);
`settings` is a protected built-in global name. The name itself cannot be overwritten.
settings = 1; // error
Use `set(name, value)` to change an application setting.
if (settings.exists('displayX')) { old_x = settings.get('displayX'); print('old displayX: ', old_x); settings.set('displayX', old_x); }
Previous: Global objects
Next: controller