BPS Script API  2.24.4
bps::Settings Class Reference

Create and query settings on the local maching and in the central datastore. More...

Public Types

enum  Scope { NoScope = 0x00000000 , LocalUserScope = 0x00000001 , LocalInstallScope = 0x00000002 , LocalSystemScope = 0x00000004 , LocalScopes = 0x00000007 , CentralUserScope = 0x00000010 , CentralSystemScope = 0x00000020 , CentralScopes = 0x00000030 , AllScopes = 0x00000037 }
 Operating scope. More...
 

Public Member Functions

Array allGroups (Scope aSearchedScopes=AllScopes)
 Find all groups within the currently opened path. More...
 
Array allKeys (Scope aSearchedScopes=AllScopes)
 Find all keys within the currently opened path. More...
 
void close ()
 Close the latest opened path. More...
 
void closeAll ()
 Close all currently opened paths. More...
 
Mixed findValue (String aKey, Mixed aDefValue, Scope aSearchedScopes=AllScopes)
 Find a value within the currently opened path. More...
 
Boolean groupExists (String aGroup)
 Check if the group exists in the current scope. More...
 
Array groups ()
 Query a list of all existing groups within the currently opened path. More...
 
Scope groupScope (String aName, Scope aSearchedScopes=AllScopes)
 Find the first scope of a group within the currently opened path. More...
 
Boolean keyExists (String aKey)
 Check if the key exists in the current scope. More...
 
Array keys ()
 Query a list of all existing keys in the currently opened group. More...
 
void open (String aPath)
 Open a new path. More...
 
void removeGroup (String aName)
 Remove a group from the currently opened path. More...
 
void removeKey (String aKey)
 Remove a key. More...
 
 Settings (Datastore aDatastore, Scope aScope=LocalScope)
 Constructor for the Settings objects. More...
 
 Settings (Scope aScope=LocalScope)
 Overloaded constructor for local only access at scopes LocalUserScope, LocalInstallScope, LocalSystemScope. More...
 
void setValue (String aKey, Mixed aValue)
 Set a value within the currently opened path. More...
 
Mixed value (String aKey, Mixed aDefValue)
 Get a value within the currently opened path. More...
 

Properties

String root
 The current root. More...
 
Scope scope
 The current scope. More...
 

Detailed Description

Create and query settings on the local maching and in the central datastore.

with (bps) {
// Access local settings only, with a default of LocalUserScope
var a = new Settings();
// Access local settings, with a default of LocalInstallScope
var b = new Settings(Settings.LocalInstallScope);
// Find a value, starting from LocalSystemScope up to CentralSystemScope
var c = new Settings(ds, Settings.LocalSystemScope);
c.open('foo/bar');
var x = c.findValue('banana', 'not found').valueOf();
}
Settings(Datastore aDatastore, Scope aScope=LocalScope)
Constructor for the Settings objects.
The bps extension is a namespace assembling general BPS properties and functions.
Definition: bps.AsyncIO.js:1

Member Enumeration Documentation

◆ Scope

Operating scope.

Enumerator
NoScope 

No valid scope.

Used for example as result by groupScope().

LocalUserScope 

Settings of the current operating system user on the local machine.

On windows this is in the registry under HKCU/Software/IBK Software AG/BPS2

LocalInstallScope 

Settings of the software installation on the locale machine.

On windows this is the file bps.conf in the same directory as the executed program. For example when the currently executed program is located in C:\Programs\IBK Software AG\BPS2\bin, the settings are in file C:\Programs\IBK Software AG\BPS2\bin\bps.conf

LocalSystemScope 

Settings valid for all users on the local machine.

On windows this is in the registry under HKLM/Software/IBK Software AG/BPS2

LocalScopes 

All local scopes.

CentralUserScope 

Central settings for the current bps user.

The settings are located in the database table t_settings.

CentralSystemScope 

Central settings for all bps users.

The settings are located in the database table t_settings.

CentralScopes 

All central scopes.

AllScopes 

All scopes.

Constructor & Destructor Documentation

◆ Settings() [1/2]

bps::Settings::Settings ( Datastore  aDatastore,
Scope  aScope = LocalScope 
)

Constructor for the Settings objects.

When the constructor is called with a first argument of type bps.Datastore, the object can access both the settings in the central datastore as well as those on the local machine. When no Datastore parameter is passed, only settings on the local machine can be accessed.

The scope is used absolutely in most methods, however in findValue(), allGroups() and allKeys() it is used as the starting scope to search through the following chain bottom up:

LocalUserScope, LocalInstallScope, LocalSystemScope, CentralUserScope, CentralSystemScope.

Parameters
aDatastoreA open database connection.
aScopeThe scope to operate on.
with (bps) {
// Access local settings only, with a default of LocalUserScope
var a = new Settings();
// Access local settings, with a default of LocalInstallScope
var b = new Settings(Settings.LocalInstallScope);
// Find a value, starting from LocalSystemScope up to CentralSystemScope
var c = new Settings(ds, Settings.LocalSystemScope);
c.open('foo/bar');
var x = c.findValue('banana', 'not found').valueOf();
}

◆ Settings() [2/2]

bps::Settings::Settings ( Scope  aScope = LocalScope)

Overloaded constructor for local only access at scopes LocalUserScope, LocalInstallScope, LocalSystemScope.

Parameters
aScopeThe scope to operate on.

Member Function Documentation

◆ allGroups()

Array bps::Settings::allGroups ( Scope  aSearchedScopes = AllScopes)

Find all groups within the currently opened path.

Search begins at the current scope and goes up to CentralSystemScope. When using the constructor without datastore, the search stops at LocalSystemScope instead of CentralSystemScope. Group names found at multiple scopes are merged into one entry.

Parameters
aSearchedScopesMask of scopes that shall be included in the search.
Returns
A list of the found group names.

◆ allKeys()

Array bps::Settings::allKeys ( Scope  aSearchedScopes = AllScopes)

Find all keys within the currently opened path.

Search begins at the current scope and goes up to CentralSystemScope. When using the constructor without datastore, the search stops at LocalSystemScope instead of CentralSystemScope. Key names found at multiple scopes are merged into one entry.

Parameters
aSearchedScopesMask of scopes that shall be included in the search.
Returns
A list of the found key names.

◆ close()

void bps::Settings::close ( )

Close the latest opened path.

var s = new bps.Settings; // HKCU/Software/IBK Software AG/BPS2
s.open('aaa'); // HKCU/Software/IBK Software AG/BPS2/aaa
s.open('bbb/ccc'); // HKCU/Software/IBK Software AG/BPS2/aaa/bbb/ccc
s.close(); // HKCU/Software/IBK Software AG/BPS2/aaa
s.close(); // HKCU/Software/IBK Software AG/BPS2
Create and query settings on the local maching and in the central datastore.
Definition: bps.Settings.js:22
void open(String aPath)
Open a new path.

◆ closeAll()

void bps::Settings::closeAll ( )

Close all currently opened paths.

The current location is set back to the root.

◆ findValue()

Mixed bps::Settings::findValue ( String  aKey,
Mixed  aDefValue,
Scope  aSearchedScopes = AllScopes 
)

Find a value within the currently opened path.

If the value is not found in the current scope, the scope chain is searched up to CentralSystemScope for such a value. When still not found, the default will be returned. When using the constructor without datastore, the search stops at LocalSystemScope instead of CentralSystemScope.

Note
Since the value is returned as a Variant, you may have to use the valueOf() method to get the text if you want a string.
var s = new bps.Settings;
var text = s.findValue('test').valueOf(); // get the plain string
Mixed findValue(String aKey, Mixed aDefValue, Scope aSearchedScopes=AllScopes)
Find a value within the currently opened path.
Parameters
aKeyThe key of the value.
aDefValueDefault value to return in case the key does not exist.
aSearchedScopesMask of scopes that shall be included in the search.
Returns
The keys value, or the provided default value in case the key does not exist.

◆ groupExists()

Boolean bps::Settings::groupExists ( String  aGroup)

Check if the group exists in the current scope.

The group name compare is done case-insensitive.

Parameters
[in]aGroupThe group to check.
Returns
True if the group exists, false if not.

◆ groups()

Array bps::Settings::groups ( )

Query a list of all existing groups within the currently opened path.

Returns
All child groups at the currently opened path.

◆ groupScope()

Scope bps::Settings::groupScope ( String  aName,
Scope  aSearchedScopes = AllScopes 
)

Find the first scope of a group within the currently opened path.

Search begins at the current scope and goes up to CentralSystemScope. When using the constructor without datastore, the search stops at LocalSystemScope instead of CentralSystemScope.

Parameters
[in]aSearchedScopesMask of scopes that shall be included in the search.
[in]aNameThe name of the group. Name compare is case-insensitive.
Returns
Scope of the first group found, or NoScope if no such group found.

◆ keyExists()

Boolean bps::Settings::keyExists ( String  aKey)

Check if the key exists in the current scope.

The key name compare is done case-insensitive.

Parameters
[in]aKeyThe key to check.
Returns
True if the key exists, false if not.

◆ keys()

Array bps::Settings::keys ( )

Query a list of all existing keys in the currently opened group.

Returns
All keys within the currently opened path.

◆ open()

void bps::Settings::open ( String  aPath)

Open a new path.

Parameters
aPathThe path to open, relative to the currently opened path.
var s = new bps.Settings; // HKCU/Software/IBK Software AG/BPS2
s.open('aaa'); // HKCU/Software/IBK Software AG/BPS2/aaa
s.open('bbb/ccc'); // HKCU/Software/IBK Software AG/BPS2/aaa/bbb/ccc

◆ removeGroup()

void bps::Settings::removeGroup ( String  aName)

Remove a group from the currently opened path.

In case no group of the given name exists, nothing happens.

Parameters
aNameThe name of the group. Name comparisation is case-insensitive.

◆ removeKey()

void bps::Settings::removeKey ( String  aKey)

Remove a key.

Parameters
aKeyName of the key to remove. Key names are case insensitive.

◆ setValue()

void bps::Settings::setValue ( String  aKey,
Mixed  aValue 
)

Set a value within the currently opened path.

Parameters
aKeyThe key for the value.
aValueThe value to save under this key.

◆ value()

Mixed bps::Settings::value ( String  aKey,
Mixed  aDefValue 
)

Get a value within the currently opened path.

Parameters
aKeyThe key of the value.
aDefValueDefault value to return in case the key does not exist.
Returns
The keys value, or the provided default value in case the key does not exist.
Note
Since the value is returned as a Variant, you may have to use the valueOf() method to get the text if you want a string.
var s = new bps.Settings;
var text = s.value('test', 'foo').valueOf(); // get the plain string
Mixed value(String aKey, Mixed aDefValue)
Get a value within the currently opened path.

Property Documentation

◆ root

String bps::Settings::root
readwrite

The current root.

The root is prepended to all paths. Initially the root is empty.

◆ scope

Scope bps::Settings::scope
readwrite

The current scope.

Must be one of LocalUserScope, LocalInstallScope, LocalSystemScope, CentralUserScope or CentralSystemScope.

var s = new bps.Settings; // HKCU/Software/IBK Software AG/BPS2
s.open('foo'); // HKCU/Software/IBK Software AG/BPS2/foo
s.scope = LocalSystemScope; // HKLM/Software/IBK Software AG/BPS2/foo
@ LocalSystemScope
Settings valid for all users on the local machine.
Definition: bps.Settings.js:70

The documentation for this class was generated from the following file: