Click or drag to resize

BLOBDirectImport Function

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.10
Syntax
 FUNCTION BLOBDirectImport(
	 nOldPointer AS USUAL,
	 cSourceFile AS USUAL
) AS USUAL
View Source

Parameters

nOldPointer
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
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.  Refer to the "Concurrency Control" chapter in the Programmer's Guide for more information on resolving concurrency conflicts.

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#
FUNCTION PutPix()
        LOCAL cBMPFile AS STRING
        LOCAL aSettings AS ARRAY
        cBMPFile := "logo.bmp"
        aSettings := {}
        // Customer database where startup parameters
        // are stored for convenience
        USE customer NEW VIA "DBFCDX"
        // Get default path settings
        AAdd(aSettings, StartPaths())
        // Get default color settings
        AAdd(aSettings, DefaultColors())
                // Get company logo for display at startup.
        // There is nothing to free because this
        // is the first time importing.
        nPointer := BLOBDirectImport(0, cBMPFile)
        AAdd(aSettings, nPointer)
        // Store the settings in the root area of
        // the customer.fpt file
        BLOBRootPut(aSettings)
See Also