Click or drag to resize

BLOBRootGet Function

X#
Retrieve the data from the root area of a BLOB file.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION BLOBRootGet() AS USUAL
Request Example View Source

Return Value

Type: Usual
The data retrieved from the root of the BLOB file.
The data type of the return value depends on the actual data stored.
Use ValType() or UsualType() to determine the data type. Note that BLOBRootGet() returns NIL if the root reference has never been written to with BLOBRootPut().
Remarks
BLOBRootGet() allows the retrieval of a BLOB from the root of a BLOB file in a work area. By default, this function operates on the currently selected work area.
It can be made to operate on an unselected work area by specifying it within an aliased expression
Tip Tip
Because the root data does not reference a particular record in the database file, the DBRLock() will not protect this root storage reference.
Therefore, if the database file is opened in shared mode, you should use BLOBRootLock() before calling BLOBRootGet().
Examples
This example uses BLOBRootGet() to read system settings from a BLOB file into an array, then demonstrates how to allow the user to modify the settings are restore them in the BLOB file:
X#
 1FUNCTION UpdateSettings()
 2    LOCAL aSettings AS ARRAY
 3    USE customer NEW SHARED VIA "DBFCDX"
 4    IF BLOBRootLock()
 5        // Get any existing settings
 6        aSettings := BLOBRootGet()
 7        IF EMPTY(aSettings)
 8            // This function would populate aSettings
 9            // with default data
10            aSettings := GetDefaultSettings()
11        ENDIF
12        // This function would allow the user to
13        // modify the settings.
14        IF ModifySettings(aSettings)
15            // Finally, store the settings
16            BLOBRootPut(aSettings)
17        ENDIF
18        BLOBRootUnLock()
19    ELSE
20        aSettings := {}
21        Alert("Could not obtain a lock on the root;
22            area")
23    ENDIF
24    CLOSE
25    RETURN aSettings
See Also