xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

BlobImport()

Imports a file into a memo field.

Syntax

BlobImport( <nFieldPos>, <cSourceFile> ) --> lSuccess

Arguments

<nFieldPos>
This is a numeric value specifying the ordinal position of the memo field to receive the contents of the file <cSourceFIle> .
<cSourceFile>
This is a character string containing the name of the file to import BLOB data from. It must be specified with a file extension. If <cSourceFile> contains no drive and/or directory information, the current directory is used. SET DEFAULT and SET PATH settings are ignored.

If <cSourceFile> does not exist, a runtime error is raised. If the file cannot be opened due to another process having exclusive access to the file, function NetErr() is set to .T. (true).

Return

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

Description

BlobImport() copies the contents of an external file into a memo field holding binary large objects (BLOB). The memo field is identified by its ordinal position, which can be obtained using function FieldPos().

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

Info

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

Example

// In this example, an image file is moved into an image
// archive database

   #include "Blob.ch"

   REQUEST DBFCDX

   PROCEDURE Main
      LOCAL nFieldPos
      LOCAL cFileName := "Sunset.jpg"

      USE PhotoArchive ALIAS Photos VIA "DBFCDX"
      APPEND BLANK

      IF .NOT. NetErr()
         nFieldPos := FieldPos( "JPEG" )
         REPLACE Photos->PhotoName WITH "Sunset in Malibu"
         REPLACE Photos->FileName  WITH cFileName

         IF BlobImport( nFieldPos, cFileName )
            FErase( cFileName )
         ENDIF
      ENDIF

      USE
   RETURN

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