xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

BlobDirectGet()

Loads data of a binary large object (BLOB) into memory.

Syntax

BlobDirectGet( <nBlobID>, [<nStart>], [<nCount>] ) --> xBlobData

Arguments

<nBlobID>
<nBlobID> is the numeric identifier of the binary large object (BLOB) to load into memory. The ID can be obtained using functions BlobDirectPut() or DbFieldInfo( DBS_BLOB_POINTER, <nFieldPos> ). An array of blob IDs can also be obtained using BlobRootGet(), when the blob IDs are previously written to the root area of a blob file.
<nStart>
This is a numeric value specifying the first byte of the BLOB to include in the returned string. If <nStart> is a positive number, data is loaded from the beginning, or the left side, of the BLOB. If <nStart> is a negative number, the data is loaded from the end, or the right side, of the BLOB.

Note:  Both parameters, <nStart> and <nCount>, are ignored if the BLOB does not contain a character string.

<nCount>
This is a numeric value specifying the number of bytes to load, beginning at position <nStart>. If omitted, all bytes from <nStart> to the end of the BLOB are loaded.

Return

The function returns the BLOB data loaded into memory. The data type of a BLOB depends on the stored BLOB. It can be determined using function Valtype().

Description

BlobDirectGet() loads the contents of a single binary large object (BLOB) into memory. The object is identified by its numeric ID. A BLOB is stored either in a memo field (DBFCDX RDD) or in a stand alone DBV file which is not associated with a database file (DBFBLOB RDD). BlobDirectGet() is usually required for the latter case. If BLOBs are stored in a database with an associated memo file, function BlobGet() is more comfortable to use, since it accepts a numeric field position of a memo field, rather than a numeric BLOB identifier.

The numeric BLOB ID is obtained using DbFieldInfo() or must be taken from the array returned by BlobRootGet().

Notes:  BLOBs are stored in memo files having the .FPT or .DBV extension. They are maintained by the RDDs DBFCDX or DBFBLOB. DBFNTX, in contrast, does not support BLOBs.

The file Blob.ch must be #included for BlobDirectGet() to work.

Info

See also:BlobDirectExport(), BlobDirectImport(), BlobDirectPut(), BlobExport(), BlobRootGet(), DbFieldInfo()
Category: Blob functions , Database functions
Header:blob.ch
Source:rdd\dbcmd.c, rdd\dbffpt\dbffpt1.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates two possibilities of loading BLOB data.
// The first example uses the DBFCDX RDD while the second uses the
// DBFBLOB RDD which does not maintain a database file, but only the
// BLOB file.

   #include "Blob.ch"

   REQUEST DBFBLOB
   REQUEST DBFCDX

   PROCEDURE Main
      LOCAL nBlobID, nFieldPos
      LOCAL aBlobID
      LOCAL cImage

      // DBF and FPT file exist
      USE PhotoArchive ALIAS Photos VIA "DBFCDX"
      LOCATE FOR FIELD->PhotoName = "Sunset in Malibu"

      IF Found()
         // Get numeric field position
         nFieldPos := FieldPos( "JPEG" )

         // Get numeric BLOB ID
         nBlobID := DbFieldInfo( DBS_BLOB_POINTER, nFieldPos )

         // Load BLOB
         cImage := BlobDirectGet( nBlobID )
         // < ... process BLOB data ... >
      ENDIF

      // Only DBV file exists
      USE BlobStorage ALIAS Blob VIA "DBFBLOB"
      aBlobID := BlobRootGet()

      IF Valtype( aBlobID ) == "A"
         // Load second BLOB
         cImage := BlobDirectGet( nBlobID[2] )
         // < ... process BLOB data ... >
      ELSE
         ? "Error: Blob root is not created"
      ENDIF

      USE
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe