KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Import 4D Write data from picture/blob field to 4D Write Pro form object
PRODUCT: 4D | VERSION: 15.x | PLATFORM: Mac & Win
Published On: December 8, 2016

Have any 4D Write data stored in a picture field and would like to import it to 4D Write Pro? Here is a utility method to do the job):

// --------------------------------------------------------------------------------
// Name: IMPORT_4DWR_FLD_TO_4DWRPRO
// Description: Method will read in 4D Write data from a picture/blob field and
// import to a 4D Write Pro form object.
//
// Input:
// $1 (POINTER) - Picture field pointer
// Output:
// $0 (OBJECT) - Object data for the 4D Write Pro form object
// --------------------------------------------------------------------------------
C_POINTER($1;$fieldPtr)
C_LONGINT($wrArea;$type)
C_BLOB($blob)
C_OBJECT($0)

If (Count parameters=1)
   $fieldPtr:=$1

   GET FIELD PROPERTIES($fieldPtr;$type)

   Case of
      :($type=Is picture)
       $wrArea:=WR New offscreen area
       WR PICTURE TO AREA ($wrArea;$fieldPtr->)
       $blob:=WR Area to blob ($wrArea;1)
       $0:=WP New($blob)
       WR DELETE OFFSCREEN AREA ($wrArea)

      : ($type=Is BLOB)
       $0:=WP New($fieldPtr->)

      Else
       // Invalid field type
   End case
End if

Here is an example of some data that is saved in a picture field when using 4D Write:



The following code will read the picture field data in 4D Write Pro:

// E.g. query a record that has a saved picture field
QUERY([Table_1];[Table_1]Field_picture="A1")

// writeProArea is a 4D Write Pro form object
writeProArea:=IMPORT_4DWR_FLD_TO_4DWRPRO (->[Table_1]Field_picture)


The result in 4D Write Pro form object:



Note: Example above will apply for blob field as well.

Commented by Tim Penner on August 8, 2017 at 3:56 PM
Although v15 can be used for converting the 4D Write document to 4D Write Pro, v15 cannot store the 4D Write Pro object/document in an Object field of the Database. If you want to store the 4D Write Pro object/document in an Object Field of the Database then you must be in v16 or higher.