Click or drag to resize

BLOBExport Function

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.08
Syntax
 FUNCTION BLOBExport(
	 nFieldPos AS USUAL,
	 cTargetFile AS USUAL,
	 kMode AS USUAL
) AS LOGIC
View Source

Parameters

nFieldPos
Type: Usual
The position of the field in the database file structure.
cTargetFile
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.  Refer to the "Concurrency Control" chapter in the Programmer's Guide for more information on resolving concurrency conflicts.
kMode
Type: Usual
A constant defining the copy mode, as shown in the table below:
Constant Description
BLOB_EXPORT_APPEND Appends to the file
BLOB_EXPORT_OVERWRITE Overwrites the file — this is the default

Return Value

Type: Boolean
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#
FUNCTION ShowPix()
        LOCAL cPixFile := "picture.gif" AS STRING
        LOCAL nPos
        // Customer database with a picture of each
        // customer stored in a field called Pix
        USE customer NEW VIA "DBFCDX"
        nPos := FIELDPOS("Pix")
        // Export the BLOB file's data
        // for the current Pix field
        IF !BLOBExport(nPos, cPixFile,;
                BLOB_EXPORT_OVERWRITE)
                        Alert("Export of picture " + cPixFile + ";
                                failed!")
        ELSE
                // Code for displaying picture would go here
        ENDIF
See Also