setpreferencevalues
setpreferencevalues
NAME
,
VALUE

The setpreferencevalues statement creates and/or modifies a preference value.

Parameters

This statement has two parameters:

name – is the name of the preference to be created or modified. The preference name must be spelled exactly, including upper/lower case. You may repeat this parameter

value – is the value to be stored in the preference. This may be text, a number, or binary data.

Description

Panorama uses OS X to manage the storage of preferences for each user. Using preferences, you can easily store user preferences persistently so that they are retained when Panorama is quit and relaunched.

Each preference has a name and a value. (Apple calls the name a “key”). You can use the setpreferencevalues statement to create a new preference, or to modify an existing one. This example creates a new preference of PGAreaCode, with a value of 714:

    setpreferencevalues "PGAreaCode","714"

Later the area code could be changed to 562:

    setpreferencevalues "PGAreaCode","562"

As shown in these examples, we recommend putting a prefix at the beginning of each preference name, for example your initials or a company name. This helps avoid the possibility of confusion between the preferences created by different authors.

As its name implies, the setpreferencevalues statement can create or modify multiple preferences at once.

    setpreferencevalues
        "NXX_SMTPHost","mail.myisp.com",
        "NXX_SMTPPort",25,
        "NXX_SMTPUserName","someguy"

Once a preference value has been set, you don’t have to do anything special to save it. It is automatically saved for future use. To access a preference value, use the getpreferencevalue( function.

    host=getpreverencevalue("NXX_SMTPHost")

#### BOOLEAN PREFERENCE VALUES

Panorama doesn’t have a special data type for Boolean values – instead it uses integer values (0 is false, anything else is true). Because of this, the setpreferencevalues statement would normally store Boolean values as an integer.

    setpreferencevalues "CWExpertMode",true()

If you want to store a preference value as a Boolean value, put the prefix `(BOOL)` or `(BOOLEAN)` in front of the preference name, like this:

    setpreferencevalues "(bool)CWExpertMode",true()

Note: The `(BOOL)` or `(BOOLEAN)` prefix is not included as part of the preference name.

If this preference is only used within Panorama, it’s really not important to explicity store a Boolean value. Either way, the function will return -1 if the preference was set to true, or 0 if it was set to false.

    getpreferencevalue("CWExpertMode") ☞ -1

However, if the preference value will be read by Objective-C or Swift code, you’ll need to explicitly store the preference value as Boolean or the Objective-C code won’t understand it. This will never happen for your preference values, but is required for some preferences that are set up by Panorama and by OS X.

One advantage of explicitly specifying Boolean is that you can then specify the Boolean value using text. All of these statements are equivalent:

    setpreferencevalues "CWExpertMode",true()
    setpreferencevalues "CWExpertMode","yes"
    setpreferencevalues "CWExpertMode","true"
    setpreferencevalues "CWExpertMode","on"
    setpreferencevalues "CWExpertMode","y"

#### SYSTEM PREFERENCE VALUES

In addition to preferences you set up, the system also manages preferences that are stored by Panorama and by the operating system. The setpreferencevalues statement can modify preferences that were stored by Panorama, but you should be very careful when doing so. Changing a preference value to an improper value could cause Panorama to operate erratically or possibly even crash.

The setpreferencevalues statement cannot modify preferences that were stored by the operating system. These can only be changed with the appropriate system interfaces, primarily the System Preference application. (You can, however, read most of these values with the getpreferencevalue( function.)

See Also

- Automatic Startup Database -- automatically open one or more databases when Panorama is launched.
- Confirmation Alerts -- Configuring alerts to confirm sensitive operations (deletions, etc.).
- getapplicationinfo( -- retrieves the value of an item in the application's plist, or a list of all plist items.
- getpreferenceclass( -- retrieves the class name of a preference value.
- getpreferencevalue( -- retrieves the value of a preference.
- info("preferencedomains") -- returns a carriage return delimited list of available preferences domains.
- preferences( -- retreives a list of preferences that have been stored.
- removepreferencevalues -- deletes one or more preference values.
- Scripting Language Configuration -- configuring the scripting languages available to Panorama (Perl, PHP, Python and Ruby).
- writepreference -- modifies a preference value.

History

Version | Status | Notes
10.0 | New | New in this version.