Class

DuSettings

DuSettings(namespaceopt, fileopt)

A class to manage settings.
Warning: DuESF stores the settings in json files and needs the right to write files, but it does not check if it has write access on the files, you should check that first using methods specific to the host application.
Constructor

# new DuSettings(namespaceopt, fileopt)

Constructs a new DuSettings instance.
Parameters:
Name Type Attributes Default Description
namespace string <optional>
DuESF.scriptName A namespace to group your settings.
file File | string <optional>
Folder.myDocuments/namespace/namespace_settings.json The file to store the settings
Properties:
Name Type Description
namespace string A namespace to group your settings.
file File The file to store the settings
data Object The settings as a js object

View Source DuESF.jsxinc, line 2995

Methods

# get() → {*}

Gets a value from the settings. The key can be a path separated by /
Properties:
Name Type Attributes Default Description
key string The setting to get
defaultValue * <optional>
null The default value if the key is not set in the settings

View Source DuESF.jsxinc, line 3113

The value
*

# load()

loads data from the settings file

View Source DuESF.jsxinc, line 3052

# reset()

Reset the settings to their default values (removes the settings file!)

View Source DuESF.jsxinc, line 3101

# save() → {boolean}

Saves data to the file.
Warning: DuESF does not check if it has write access on the files, you should check that first using methods specific to the host application.

View Source DuESF.jsxinc, line 3068

true if the file has been correctly written
boolean

# set()

Sets a value to the settings. The key can be a path separated by /
Properties:
Name Type Description
key string The setting to set
value * The value to set

View Source DuESF.jsxinc, line 3130

# setFile(file)

Sets the file to be used to save the settings
Parameters:
Name Type Description
file File | string The file or path to the file

View Source DuESF.jsxinc, line 3086