Click or drag to resize

BLOBRootGet Function

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

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.08
Syntax
 FUNCTION BLOBRootGet() AS USUAL
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. Note:  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#
FUNCTION UpdateSettings()
        LOCAL aSettings AS ARRAY
        USE customer NEW SHARED VIA "DBFCDX"
        IF BLOBRootLock()
                // Get any existing settings
                aSettings := BLOBRootGet()
                IF EMPTY(aSettings)
                        // This function would populate aSettings
                        // with default data
                        aSettings := GetDefaultSettings()
                ENDIF
                // This function would allow the user to
                // modify the settings.
                IF ModifySettings(aSettings)
                        // Finally, store the settings
                        BLOBRootPut(aSettings)
                ENDIF
                BLOBRootUnlock()
        ELSE
                aSettings := {}
                Alert("Could not obtain a lock on the root;
                        area")
        ENDIF
        CLOSE
        RETURN aSettings
See Also