Sash XB for Linux
Home |  Documentation  ... Contact

Using the SashXB Registry extension


The SashXB registry extension provides functionality similar to that of the Windows registry. It is the natural extension to use when saving user preferences, history and similar things. The registry is stored in XML format and is editable as ASCII text, at least in theory. You can use sash-registry-editor to poke around and get a feel for what goes into a registry.

1. Sash.Registry

The easiest way to picture a registry structure is to think of a directory structure - the registry keys are folders and the registry values are files of one of the five allowed types. The *Weblication* methods operate on the weblication registry, while the other methods require a root base key to be specified as the first parameter. For example,

DeleteWeblicationKey('\\Preferences\\Display');

is equivalent to

DeleteKey('{Weblication-Global-Unique-ID}', '\\Preferences\\Display');

For the purposes of most weblications, local (weblication-only) registry access should be sufficient. Keys can be specified as \ (back-slash) separated paths. Remember that '\' is an escape symbol in JavaScript.


Methods
boolean CreateWeblicationKey(string newKey)
Create a new key for the weblication with name specified by the string newKey . Returns true on success
boolean DeleteWeblicationKey(string key)
Deletes the weblication key with name specified by key. Returns true on success
boolean DeleteWeblicationValue(string key, valueName)
Deletes the value field valueName from the key given by key . Returns true on success
{string, array, boolean, long, float} QueryWeblicationValue(string key, string valueName)
Returns the data stored in the value field valueName of key. May return a string, array of strings, boolean, integer or floating point value
boolean SetWeblicationValue(string key, string valueName, {string, array, boolean, long, float}data)
Sets the contents of the value field valueName of key to data. The allowed types for data are: string, array of strings, boolean, integer and floating point numbers. Returns true on success
array EnumWeblicationKeys(string key)
Returns an array of strings representing all immediate sub-keys of the given key. You can use this function to traverse the weblication registry
array EnumWeblicationValues(string key)
Returns an array of strings representing all names of value fields of the given key. You can use this function to traverse the weblication registry
boolean CreateKey(string rootKey, string newKey)
Same as CreateWeblicationKey(...) , but with base registry specified by rootKey
boolean DeleteKey(string rootKey, string key)
Same as DeleteWeblicationKey( ...), but with base registry specified by rootKey
boolean DeleteValue(string rootKey, string key, string valueName)
Same as DeleteWeblicationValue(... ), but with base registry specified by rootKey
{string, array, boolean, long, float} QueryValue( rootKey, key, valueName)
Same as QueryWeblicationValue(... ), but with base registry specified by rootKey
boolean SetValue(string rootKey, string key, string valueName, {string, array, boolean, long, float} data)
Same as SetWeblicationValue(... ), but with base registry specified by rootKey
array EnumKeys(string rootKey, string key)
Same as EnumWeblicationKeys(...) , but with base registry specified by rootKey
array EnumValues(string rootKey, string key)
Same as EnumWeblicationValues( ...), but with base registry specified by rootKey

2. Quick example

Sash.Registry.CreateWeblicationKey('\\You\\Can\\Provide\\Multiple\\Key\\Levels'); // remember that \ is an escape symbol
Sash.Registry.SetWeblicationValue('\\You\\Can', 'just_do_it', true);
var reg= Sash.Registry; // save yourself some typing
print(reg.EnumWeblicationValues('\\You\\Can')); // should return one-item array [ 'just_do_it' ]
reg.DeleteWeblicationKey('\\You'); // recursively deletes everything under the key 'You'


Wing Yung, Stefan Atev
Last modified: Wed Mar 20 16:49:26 EST 2002

  
© Copyright 2002, All Rights Reserved. Contact