Click or drag to resize

BLOBGet Function

X#
Get the contents of a BLOB, identified by its memo field number.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION BLOBGet(
	nFieldPos,
	nStart,
	nCount
) AS USUAL CLIPPER
Request Example View Source

Parameters

nFieldPos (Optional)
Type: Usual
The position of the field in the database file structure.
nStart (Optional)
Type: Usual
The starting position in the memo field of the BLOB data.
If nStart is positive, the starting position is relative to the leftmost character in nFieldPos.
If nStart is negative, it is relative to the rightmost character in nFieldPos.
If nStart is omitted, it is assumed to be 1.
nCount (Optional)
Type: Usual
The number of bytes of data to retrieve, beginning at nStart.
If nCount is larger than the amount of data stored, excess data is ignored.
If omitted, BLOBGet() retrieves to the end of the data.

Return Value

Type: Usual
The BLOB data retrieved from the memo field.
The data type of the return value depends on the actual data stored.
Use ValType() or UsualType() to determine the data type.
If the indicated field is not a memo field, BLOBGet() returns NIL.
Remarks
BLOBGet() is very similar to FieldGet(). However, because string type variables cannot be larger than 64 KB, FieldGet() will raise a runtime error when attempting to retrieve memo fields of this magnitude or greater. BLOBGet() will also raise an error if you attempt to retrieve a field greater than this magnitude; however, you can retrieve any subset of the BLOB data by using an nCount less than 64 KB. 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
Tip Tip
BLOB data less than 64 KB can be retrieved from a memo field using standard means (for example, referring to the field by name in an expression or using the FieldGet() function).
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 GetFirst25()
 2    LOCAL nPos
 3    LOCAL cStr AS STRING
 4    USE customer NEW INHERIT FROM {"DBFBLOB"}
 5    // Field that contains word processor
 6    // documentation
 7    nPos := FIELDPOS("WP_DOC")
 8        // Import a file (can be larger than 64 KB), then
 9    // obtain the first 25 characters to show to the
10    // user
11    IF BLOBImport(nPos, "c:\application\temp.doc")
12        cStr := BLOBGet(nPos, 1, 25)
13    ELSE
14        cStr := "Error: could not import file!"
15    ENDIF
16CLOSE
17RETURN cStr
See Also