Click or drag to resize

BLOBImport Function

X#
Read the contents of a file as a BLOB, identified by a memo field number.

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

Parameters

nFieldPos (Optional)
Type: Usual
The position of the field in the database file structure.
cSourceFile (Optional)
Type: Usual
The name of the file from which to read the BLOB data, including an optional drive, directory, and extension. See SetDefault() and SetPath() for file searching and creation rules. No default extension is assumed.
This function attempts to open cSourceFile in shared mode.
If the file does not exist, a runtime error is raised.
If the file is successfully opened, the operation proceeds.
If access is denied because, for example, another process has exclusive use of the file, NetErr() is set to TRUE.

Return Value

Type: Logic
TRUE if successful; otherwise, FALSE.
Remarks
BLOBImport() provides a mechanism for copying the contents of a file into a memo field as BLOB data. 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
BLOBImport() is used in conjunction with BLOBExport() to transfer BLOB data back and forth between files and memo fields. You can use BLOBImport() with a variety of file types, including graphics images, word processor files, and printer fonts.
These two functions are excellent for creating databases of documents, graphics, sounds, and so on.
Tip Tip
DBFieldInfo(DBS_BLOB_TYPE, nFieldPos) will return "C" (string) for any memo field created using BLOBImport().
Examples
This example imports information from a word processing document into a field, then uses BLOBGet() to extract the first 25 characters of the field:
X#
 1FUNCTION Populate()
 2    USE customer NEW INHERIT FROM {"DBFBLOB"}
 3    // Construct unique file name based on last
 4    // name and id
 5    DO WHILE .NOT. EOF()
 6        GetPix("Pix", SUBSTR(LastName, 1, 4) + CustID)
 7        Customer->DBSkip()
 8    ENDDO
 9FUNCTION GetPix(cPixField, cPixFile)
10    LOCAL nPos
11    nPos := FIELDPOS(cPixField)
12    // Import the picture file into indicated field
13    IF !BLOBImport(nPos, cPixFile)
14        Alert("Import of picture " + cPixFile + "; failed!")
15    ENDIF
See Also