Click or drag to resize

BLOBDirectImport Function

X#
Import a file into a BLOB file and return a pointer to the data.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax
 FUNCTION BLOBDirectImport(
	nOldPointer,
	cSourceFile
) AS USUAL CLIPPER
Request Example View Source

Parameters

nOldPointer (Optional)
Type: Usual
A pointer to the BLOB data which will be released after the import.
This pointer can be obtained using BLOBDirectPut(), BLOBDirectImport(), or DBFieldInfo(DBS_BLOB_POINTER, nFieldPos). Passing 0 disables the release of data.
If specified, BLOBDirectImport() releases the space associated with nOldPointer for reuse by other data.
Therefore, it is illegal to use nOldPointer with any of the BLOB functions after passing it as an argument to this function.
Use the function's return value to refer to the newly stored data.
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: Usual
A numeric pointer to the BLOB image stored in cSourceFile.
Remarks
BLOBDirectImport() provides a mechanism for copying the contents of a file into a BLOB file. 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
BLOBDirectImport() is used in conjunction with BLOBDirectExport() to transfer data back and forth between external files and BLOB files. You can use BLOBDirectImport() 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. After importing a file with BLOBDirectImport(), nNewPointer, the return value, is the only way to access the data from the BLOB file.
It is up to you, the developer, to provide permanent storage for this reference (see example below) Note: DBFieldInfo(DBS_BLOB_TYPE, nFieldPos) will return "C" (string) for any memo field created using BLOBDirectImport().
Examples
This example imports a .BMP file to be part of an array of startup data.
The data, stored in the root area of the BLOB file, could then be used to display the application's startup screen:
X#
 1FUNCTION PutPix()
 2    LOCAL cBMPFile AS STRING
 3    LOCAL aSettings AS ARRAY
 4    cBMPFile := "logo.bmp"
 5    aSettings := {}
 6    // Customer database where startup parameters
 7    // are stored for convenience
 8    USE customer NEW VIA "DBFCDX"
 9    // Get default path settings
10    AAdd(aSettings, StartPaths())
11    // Get default color settings
12    AAdd(aSettings, DefaultColors())
13        // Get company logo for display at startup.
14    // There is nothing to free because this
15    // is the first time importing.
16    nPointer := BLOBDirectImport(0, cBMPFile)
17    AAdd(aSettings, nPointer)
18    // Store the settings in the root area of
19    // the customer.fpt file
20    BLOBRootPut(aSettings)
See Also