Previous: , Up: GUI Development   [Contents][Index]


35.5 User-Defined Preferences

: val = getpref ("group", "pref")
: val = getpref ("group", "pref", default)
: {val1, val2, …} = getpref ("group", {"pref1", "pref2", …})
: prefstruct = getpref ("group")
: prefstruct = getpref ()

Return the preference value corresponding to the named preference pref in the preference group group.

The named preference group must be a string.

If pref does not exist in group and default is specified, create the preference with value default and return default.

The preference pref may be a string or cell array of strings. If it is a cell array of strings then a cell array of preferences is returned.

The corresponding default value default may be any Octave value, .e.g., double, struct, cell array, object, etc. Or, if pref is a cell array of strings then default must be a cell array of values with the same size as pref.

If neither pref nor default are specified, return a structure of preferences for the preference group group.

If no arguments are specified, return a structure containing all groups of preferences and their values.

See also: addpref, setpref, ispref, rmpref.

: setpref ("group", "pref", val)
: addpref ("group", {"pref1", "pref2", …}, {val1, val2, …})

Set the preference pref to the given val in the named preference group group.

The named preference group must be a string.

The preference pref may be a string or a cell array of strings.

The corresponding value val may be any Octave value, .e.g., double, struct, cell array, object, etc. Or, if pref is a cell array of strings then val must be a cell array of values with the same size as pref.

If the named preference or group does not exist, it is added.

See also: addpref, getpref, ispref, rmpref.

: addpref ("group", "pref", val)
: addpref ("group", {"pref1", "pref2", …}, {val1, val2, …})

Add the preference pref and associated value val to the named preference group group.

The named preference group must be a string.

The preference pref may be a string or a cell array of strings. An error will be issued if the preference already exists.

The corresponding value val may be any Octave value, .e.g., double, struct, cell array, object, etc. Or, if pref is a cell array of strings then val must be a cell array of values with the same size as pref.

See also: setpref, getpref, ispref, rmpref.

: rmpref ("group", "pref")
: rmpref ("group", {"pref1", "pref2", …})
: rmpref ("group")

Remove the named preference pref from the preference group group.

The named preference group must be a string.

The preference pref may be a string or cell array of strings.

If pref is not specified, remove the preference group group.

It is an error to remove a nonexistent preference or group.

See also: addpref, ispref, setpref, getpref.

: ispref ("group", "pref")
: ispref ("group", {"pref1", "pref2", …})
: ispref ("group")

Return true if the named preference pref exists in the preference group group.

The named preference group must be a string.

The preference pref may be a string or a cell array of strings.

If pref is not specified, return true if the preference group group exists.

See also: getpref, addpref, setpref, rmpref.

: prefdir
: prefdir (1)
: dir = prefdir

Return the directory that holds the preferences for Octave.

Examples:

Display the preferences directory

prefdir

Change to the preferences folder

cd (prefdir)

If called with an argument, the preferences directory is created if it doesn’t already exist.

See also: getpref, setpref, addpref, rmpref, ispref.

: preferences

Display the GUI preferences dialog window for Octave.


Previous: , Up: GUI Development   [Contents][Index]