BLOB TO DOCUMENT

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 6.0


BLOB TO DOCUMENT (document; blob{; *})

ParameterTypeDescription
documentStringName of the document
blobBLOBNew contents for the document
**On Macintosh only:
Resource fork is written if * is passed;
otherwise, Data fork is written

Description

BLOB TO DOCUMENT rewrites the whole contents of document using the data stored in blob. If you want to let the user choose the document, use the commands Open document or Create document and use 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 BLOB TO DOCUMENT rewrites the Data fork of the document. To rewrite 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 which allows you to save a document that will contain the data previously loaded into a BLOB field. The method for this button could be:

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

See Also

Create document, DOCUMENT TO BLOB, Open document.

System Variables

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

Error Handling

If you try to rewrite a document that does not exist or that is already open by another process or application, the appropriate File Manager error is generated.

The disk space may be insufficient for writing the new contents of the document.

I/O errors can occur while writing the document.

In all cases, you can trap the error using an ON ERR CALL interruption method.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next