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.19
Syntax FUNCTION BLOBDirectImport(
nOldPointer,
cSourceFile
) AS USUAL CLIPPER
[ClipperCallingConventionAttribute(new string[] { ... })]
public static Usual BLOBDirectImport(
Usual nOldPointer = default,
Usual cSourceFile = default
)
Request Example
View SourceParameters
- 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)
Tip |
---|
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:
1FUNCTION PutPix()
2 LOCAL cBMPFile AS STRING
3 LOCAL aSettings AS ARRAY
4 cBMPFile := "logo.bmp"
5 aSettings := {}
6
7
8 USE customer NEW VIA "DBFCDX"
9
10 AAdd(aSettings, StartPaths())
11
12 AAdd(aSettings, DefaultColors())
13
14
15
16 nPointer := BLOBDirectImport(0, cBMPFile)
17 AAdd(aSettings, nPointer)
18
19
20 BLOBRootPut(aSettings)
See Also