KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Determine if a blob exported from 4D Write Pro is a MS Word ".DOCX" type
PRODUCT: 4D | VERSION: 17 R4 | PLATFORM: Mac & Win
Published On: February 14, 2019

In v17R4, 4D Write Pro documents can be exported to be of MS Word ".DOCX" type. Where the document can be opened in MS Word. One option could be to export to a blob by using the WP EXPORT VARIABLE command which can be stored in the database. This data might not be easily recognized on what type of blob it is. The following utility method can determine if the blob is of MS Word ".DOCX":

// ----------------------------------------------------------------------
// Name: BLOB_IS_WORD_DOCX
// Description: Method will determine if the blob is a MS WORD ".DOCX"
// format that was exported with WP EXPORT VARIABLE.
// Parameters:
// $1 (BLOB) - Blob to check if it is a MS WORD ".DOCX"
//
// Output:
// $0 (BOOLEAN) - True - MS WORD ".DOCX", False - Not MS WORD ".DOCX"
// -----------------------------------------------------------------------
C_BLOB($1;$blob)
C_BOOLEAN($0)
C_TEXT($blobText)
C_LONGINT($pos)

$blob:=$1

$blobText:=BLOB to text($blob;Mac text without length)
$pos:=Position("word";$blobText)

If ($pos>0)
  $0:=True
Else
  $0:=False
End if



Here is an example of using the method:

C_BLOB($blob)
C_BOOLEAN($status)

WP EXPORT VARIABLE(WriteProArea;$blob;wk docx)

$status:=BLOB_IS_WORD_DOCX($blob) //true


See Also: