# read-registry(2)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

read-registry - Read in a registry definition file

## SYNOPSIS

read-registry "root" "file" "mode"

## DESCRIPTION

read-registry loads a registry file erf(8) into the internal registry memory, where the information may be queried via the registry macro commands. The arguments are defined as follows:-

root

The root node in the registry to into which the registry contents are attached. The root name is limited to 32 characters in length and is specified without a leading forward slash '`/`'. The node root is created at the root of the registry.

file

The name of the registry file erf(8) to load. This may be an absolute, relative or a $search-path(5) specified file; typically it is located on $search-path.

mode

The mode is string specifying the registry node loading and saving modes, each mode is represented by a character. Lower case characters add a mode, upper case characters delete a mode. The modes are defined as follows:-

a - Autosave

Automatically saves the registry when it is deleted or unloaded from the registry. The user is not prompted for a save.

b - Backup

Automatically performs a backup of the registry file whenever a save operation is performed.

c - Create

If the registry file cannot be loaded then the root node is created and the invocation succeeds. If this mode is omitted then the call fails if the file cannot be found.

d - Discard

Marks the registry as discardable. This is typically used for registries that are not saved.

r - Reload

If the registry node already exists then it is deleted and reloaded, see also the merge flag (m). By default, when both the r and m flags are omitted and the registry node already exists the read operation is not performed and the existing node is used.

m - Merge

The registry file is merged with the contents of any existing registry node. (i.e. the existing registry tree nodes are not deleted if they already exist). See also the reload flag (r).

h - Hidden

The registry node is created in the Hidden state. (i.e. children will not be shown in list-registry(2) output). Refer to mark-registry(2) for hiding modes.

u - Updated

Marks the registry as modified. The modified bit is removed when the registry file is saved. If the modified bit is applied to a registry node the user will be prompted to save the registry when it is deleted (or it will be automatically saved when the Autosave mode is used).

Multiple modes may be applied.

## EXAMPLE

The following example is a typical call made from a macro using a registry file where the user may edit the registry file. In this case this a reload of the registry is forced to ensure that the most up-to-date contents are retrieved. Note that the name of the registry file is actually retrieved from the history registry.

    set-variable #l1 &reg "/history/address" $user-name
    !if &seq &set #l0 &find #l1 ".ab" "ERROR"
        set-variable #l0 &reg "/history" ""
        set-variable #l0 &spr "%s%s.ab" &lef #l0 &rsin "/" #l0 #l1
    !endif
    read-registry "AddressBook" #l0 "rc"

## BUGS

At exit only registry nodes attached to the root are saved.

## SEE ALSO

copy-registry(3), delete-registry(2), find-registry(2), list-registry(2), mark-registry(2), save-registry(2), set-registry(2), &reg(4), $search-path(5), erf(8).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>