xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

BlobExport()

Exports the contents of a memo field holding a binary large object (BLOB) to a file.

Syntax

BlobExport( <nFieldPos>, <cTargetFile>, [<nMode>] ) --> lSuccess

Arguments

<nFieldPos>
This is a numeric value specifying the ordinal position of the memo field holding the BLOB to be exported.
<cTargetFile>
This is a character string containing the name of the file to receive the exported data. It must be specified with a file extension. If <cTargetFile> contains no drive and/or directory information, the current directory is used. SET DEFAULT and SET PATH settings are ignored.
<nMode>
A numeric value specifying how to write data to the target file. #define constants must be used for this parameter.

Constants for BlobExport()
ConstantDescription
BLOB_EXPORT_APPENDAppends to the target file
BLOB_EXPORT_OVERWRITE *)Overwrites the target file

Return

The return value is .T. (true) if data is successfully exported, otherwise .F. (false) is returned.

Description

BlobExport() copies the contents of a single binary large object (BLOB) to an external file. The object is identified by the ordinal position of the memo field holding the BLOB data. This position can be obtained using function FieldPos().

If the target file does not exist, it is created. If it exists, it is either overwritten or data is appended to the file, depending on <nMode>. When the file operation fails, BlobExport() returns .F. (false) and function NetErr() is set to .T. (true). This can happen when the target file is currently locked by another process in concurrent file access.

Note:  the file Blob.ch must be #included for BlobExport() to work.

Info

See also:BlobDirectGet(), BlobDirectExport(), BlobDirectImport(), BlobDirectPut(), 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 how to export BLOB data to an external file.

   #include "Blob.ch"

   REQUEST DBFCDX

   PROCEDURE Main
      LOCAL nFieldPos

      USE PhotoArchive ALIAS Photos VIA "DBFCDX"
      LOCATE FOR FIELD->PhotoName = "Sunset in Malibu"

      IF Found()
         nFieldPos := FieldPos( "JPEG" )

         IF BlobExport( nFieldPos, "Sunset.jpg" )
            ? "File successfully eported"
         ELSE
            ? "Unable to export BLOB data"
         ENDIF
      ENDIF

      USE
   RETURN

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