Click or drag to resize

BLOBDirectExport Function

X#
Export the contents of a binary large object (BLOB) pointer to a file.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION BLOBDirectExport(
	nPointer,
	cTargetFile,
	kMode
) AS LOGIC CLIPPER
Request Example View Source

Parameters

nPointer (Optional)
Type: Usual
A pointer to the BLOB data.
This pointer can be obtained using BLOBDirectPut(), BLOBDirectExport(), or DBFieldInfo(DBS_BLOB_POINTER, nFieldPos).
cTargetFile (Optional)
Type: Usual
The name of the target file where the BLOB data will be written, including an optional drive, directory, and extension. See SetDefault() and SetPath() for file searching and creation rules. No default extension is assumed.
If cTargetFile does not exist, it is created.
If it exists, this function attempts to open the file in exclusive mode and, if successful, the file is written to without warning or error.
If access is denied because, for example, another process is using the file, NetErr() is set to TRUE.
kMode (Optional)
Type: Usual
A constant defining the copy mode, as shown in the table below:
ConstantDescriptionBLOB_EXPORT_APPENDAppends to the fileBLOB_EXPORT_OVERWRITEOverwrites the file — this is the default

Return Value

Type: Logic
TRUE if successful; otherwise, FALSE.
Remarks
Tip Tip
A BLOB file (.DBV or .FPT) is used for storing memo field information, as an alternative to the standard .DBT file mechanism supported by some RDDs.
It is a more powerful and efficient mechanism for storing and retrieving large amounts of data than using .DBT files. X# supplies the DBFCDX driver, which uses the BLOB file storage mechanism by default, and the DBFBLOB driver, which you can use as an inherited driver with other RDDs.
Remarks
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
Examples
This example extracts an array of pointers from the BLOB file's root area, then uses one of the pointers to export a picture to a file:
X#
 1FUNCTION PutPix()
 2    LOCAL cPixFile AS STRING
 3    LOCAL nPointer
 4    LOCAL aBLOBPtrs AS ARRAY
 5    cPixFile := "picture.gif"
 6    // Customer database with a picture of
 7    // each customer stored in a field called Pix
 8    USE customer NEW VIA "DBFCDX"
 9    // Assumes that the program previously
10    // stored an array of direct BLOB pointers
11    // into the root area of the BLOB file.
12    // The picture that we want is assumed to
13    // be the second array element.
14    aBLOBPtrs := BLOBRootGet()
15    nPointer := aBLOBPtrs[2]
16    // Export picture pointed to by nPointer to a file
17    IF !BLOBDirectExport(nPointer, cPixFile, ;
18        BLOB_EXPORT_OVERWRITE)
19            Alert("Export of picture " + cPixFile + ";
20                failed!")
21    ELSE
22        // Code for displaying picture would go here
23    ENDIF
See Also