Click or drag to resize

BLOBExport Function

X#
Copy the contents of a BLOB, identified by its memo field number, to a file.

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

Parameters

nFieldPos (Optional)
Type: Usual
The position of the field in the database file structure.
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
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 exports the contents of a field that stores a picture to a .GIF file, so that the file can be programmatically displayed:
X#
 1FUNCTION ShowPix()
 2    LOCAL cPixFile := "picture.gif" AS STRING
 3    LOCAL nPos
 4    // Customer database with a picture of each
 5    // customer stored in a field called Pix
 6    USE customer NEW VIA "DBFCDX"
 7    nPos := FIELDPOS("Pix")
 8    // Export the BLOB file's data
 9    // for the current Pix field
10    IF !BLOBExport(nPos, cPixFile,;
11        BLOB_EXPORT_OVERWRITE)
12            Alert("Export of picture " + cPixFile + ";
13                failed!")
14    ELSE
15        // Code for displaying picture would go here
16    ENDIF
See Also