4D v14.3

DOCUMENT TO BLOB

Home

 
4D v14.3
DOCUMENT TO BLOB

DOCUMENT TO BLOB 


 

DOCUMENT TO BLOB ( document ; blob {; *} ) 
Parameter Type   Description
document  String in Name of the document
blob  BLOB in BLOB field or variable to receive the document
in Document contents
Operator in On Macintosh only: Resource fork is loaded if * is passed otherwise Data fork is loaded

DOCUMENT TO BLOB loads the whole contents of document into blob. You must pass the name of an existing document that is not already open, otherwise an error will be generated. To let the user choose the document to be loaded into the BLOB, use the command Open document and the process variable document (see Example).

Note regarding Macintosh: Macintosh documents can be composed of two forks: the Data fork and the Resource fork. By default, the command DOCUMENT TO BLOB loads the Data fork of the document. To load the Resource fork of the document instead, pass the optional * parameter. On Windows, the optional * parameter is ignored. Note that the 4D environment provides the equivalent of Mac OS resource forks on Windows. For example, the data fork of a 4D database is stored in a file with the file extension .4DB; the resource fork is stored in a file with the same name and the file extension .RSR. On Windows, if you write a 4D application with the data fork and resource fork stored in BLOBs, you just need to access the file corresponding to the fork with which you want to work.

Example  

You write an Information System that enables you to quickly store and retrieve documents. In a data entry form, you create a button that allows you to load a document into a BLOB field. The method for this button could be:

 $vhDocRef:=Open document("") ` Select the document of your choice
 If(OK=1) ` If a document has been chosen
    CLOSE DOCUMENT($vhDocRef` We don't need to keep it open
    DOCUMENT TO BLOB(Document;[YourTable]YourBLOBField` Load the document
    If(OK=0)
  ` Handle error
    End if
 End if

OK is set to 1 if the document is correctly loaded, otherwise OK is set to 0 and an error is generated.

  • If you try to load (into a BLOB) a document that does not exist or that is already open by another process or application, the appropriate File Manager error is generated.
  • An I/O error can occur if the document is locked, located on a locked volume, or if there is problem in reading the document.
  • If there is not enough memory to load the document, an error -108 is generated.

In each case, you can trap the error using an ON ERR CALL interruption method.

 
PROPERTIES 

Product: 4D
Theme: BLOB
Number: 525

The OK variable is changed by the commandMac OS specific

 
HISTORY 

Created: 4D v6

 
SEE ALSO 

BLOB TO DOCUMENT
Open document

 
TAGS 

Document, Data fork, Resource fork, Storing documents

 
ARTICLE USAGE

4D Language Reference ( 4D v11 SQL Release 6)
4D Language Reference ( 4D v12.4)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)