KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility method to convert and export 4D Write documents to RTF
PRODUCT: 4D | VERSION: 13.2 | PLATFORM: Mac & Win
Published On: March 29, 2013

This Technical Tip provides a utility method for converting and exporting 4D Write documents from a given field in a table to a RTF document.

// ----------------------------------------------------
// Method: UTIL_Export_4DWrite_to_RTF
// Description
//   This is a utility method to convert and export all
//   4D Write documents from a given table and field to RTF

//
// Parameters
//   $1 (Pointer) - Pointer to the table contain 4D Write documents to be converted
//                  and exported

//   $2 (Pointer) - Pointer to field containing the document name
//   $3 (Pointer) - Pointer to the field containing the 4D Write documents
//   $4 (Text) - Path to folder where all documents should be exported to
//
// ----------------------------------------------------

C_POINTER($1;$table_p)
C_POINTER($2;$doc_name_p)
C_POINTER($3;$pic_field_p)
C_TEXT($4;$folder_path)
C_LONGINT(temp)

$table_p:=$1
$doc_name_p:=$2
$pic_field_p:=$3
$folder_path:=$4

ALL RECORDS($table_p->)
$recTotal:=Records in selection($table_p->)

//reserve space in memory for a 4D Write area that is invisible to you and the user
temp:=WR New offscreen area
For ($recNum;1;$recTotal)
   WR PICTURE TO AREA (temp;$pic_field_p->) //or WR BLOB TO AREA if 4D Write documents
                                            //are stored in a blob

   WR SAVE DOCUMENT (temp;$folder_path+$doc_name_p->;wr RTF document)
   NEXT RECORD($table_p->)
End for
//delete the 4D Write area that was created with WR New offscreen area and free the
//memory used by the offscreen area

WR DELETE OFFSCREEN AREA (temp)


Here is an example of how the utility method can be called:

UTIL_Export_4DWrite_to_RTF (->[Table_1];->[Table_1]Doc_Name;->[Table_1]Write_Pic_;\
  $destinationPath)