4D v16.3

Converting 4D Write documents to 4D Write Pro

Home

 
4D v16.3
Converting 4D Write documents to 4D Write Pro

Converting 4D Write documents to 4D Write Pro    


 

4D Write Pro can open and convert legacy 4D Write documents while supporting most of their specific properties:

In the picture above, we have a 4D Write area on the left and a 4D Write Pro area on the right (created using the new library object - see below). The contents of the 4D Write area were recovered simply using the WP New command:

  // we retrieve the contents of the 4D Write area in the 4D Write Pro area
 [WRITEAREAS]AreaNTWP:=WP New([WRITEAREAS]AreaNT_)

But since 4D Write can only be used with 32-bit versions of 4D v16, you must convert your 4D Write documents before changing to the 64-bit version.

Unlike 4D Write, 4D Write Pro is not a plug-in but is fully integrated into 4D itself. Note that 4D Write Pro uses the same license as 4D Write. You need to have this license installed in your application in order to enable the feature.

4D Write Pro objects permit 4D Write documents to be retrieved in two ways:

  • For 4D Write files stored on disk, you can use the WP Import document command. 4D Write files (.4w6, .4w7, and .4wt - template) must be converted in 4D Write Pro files (.4wp).
      // First, convert .4w6 files in .4w7 files with 4D Write commands
     $offscreen:=WR New offscreen area
     WR OPEN DOCUMENT($offscreen;"myFile.4w6";"4WR6")
     WR SAVE DOCUMENT($offscreen;"myFile.4w7";"4WR7")
     WR DELETE OFFSCREEN AREA($offscreen)


      // Then convert .4w7 in .4wp with 4D Write Pro commands
     C_OBJECT($docWritePro)
     $docWritePro:=WP Import document("myFile.4w7")
     WP EXPORT DOCUMENT($docWritePro;"myFile.4wp")
  • For 4D Write files stored in the data file, you can use the WP New command. 4D Write files stored in BLOB or Picture fields must be moved to Object fields.
      // From a Picture field to an Object field, through a BLOB
      // [DocWRITE]WritePictArea_ is a picture field
      // $Blob is a BLOB
      // [DocWRITE]WriteProArea is an Object field
     $offscreen:=WR New offscreen area
     WR PICTURE TO AREA($offscreen;[DocWRITE]WritePictArea_)
     $Blob:=WR Area to blob($offscreen;1)
     [DocWRITE]WriteProArea :=WP New($Blob)


      // From a BLOB field to an Object field
      // [DocWRITE]WriteBLOBArea_ is a BLOB field
      // [DocWRITE]WriteProArea is an object field
     [DocWRITE]WriteProArea :=WP New([DocWRITE]WriteBLOBArea_)
     WR DELETE OFFSCREEN AREA($offscreen)

Compatibility notes:

  • Only 4D Write documents of the last generation ("4D Write v7") are supported.
  • Check which features and objects can be imported by consulting:  Which properties will be recovered from 4D Write?
  • Copying-pasting from a 4D Write document to a 4D Write Pro area is not supported for the moment. A 4D Write document can only be imported using 4D Write Pro language commands.
  • Under Windows, 4D Write Pro features rely on Direct2D. WIth machines under Windows 7 or Windows Server 2008, make sure that the Platform Update for Windows component has been installed so that you can benefit from the required Direct2D version.

In 4D v16, the library of preconfigured objects in the Form editor includes the new 4D Write Pro form object. Dragging and dropping this object onto a form automatically inserts a preconfigured 4D Write Pro area with an associated 4D Write Pro Widget subform containing control panels to manage the area's contents:

         

For more information, see 4D Write Pro area.

In your database structure, any 4D Object field can be used to store 4D Write Pro documents. Once the Object field intended to store your 4D Write Pro documents is defined, you can just reference it from the form containing the area. In the Form editor, enter the field name using the standard "[Table]Field" notation in the Variable Name area of the Property List for the 4D Write Pro area:

   

Your 4D Write Pro area is then associated with the Object type field.

Filtering was not enabled for 4D Write Pro documents in previous versions. If your 4D Write Pro documents reference 4D methods, they will no longer be evaluated correctly once they are converted into 4D v16 or higher. "## Error # 48" messages will be displayed instead.
In this case, you must add the methods to the list of allowed methods using the SET ALLOWED METHODS command.

New commands have been added and existing ones have evolved to work with 4D Write Pro:

  • OBJECT SET HORIZONTAL ALIGNMENT: This command supports 4D Write Pro objects. For 4D Write Pro areas only, a new wk justify constant is now available for the alignment parameter for 4D Write Pro objects, allowing you to set a justified alignment.
  • OB SET: This command supports the definition of attributes in 4D Write Pro objects, the same way as WP SET ATTRIBUTES. The following syntax is supported:
    OB SET ( objSel | wpDoc; attribName ; attribValue {; attribName2 ; valeurAttrib2 ; ... ; attribNameN ; attribValueN} )

    Limitation: you cannot pass a picture field or variable directly as an attribute value.
  • OB Get: This command supports the definition of attributes in 4D Write Pro objects, the same way as WP GET ATTRIBUTES. The following syntax is supported:
    OB Get ( objSel | wpDoc; attribName ) -> Function result

    This command has the same limitation as OB SET: you cannot use a picture field or variable directly as an attribute value.
  • "Stringifying" 4D Write Pro attributes: If you convert a 4D Write Pro object into JSON using JSON Stringify, only the "title" attribute will be available in the output string.
    Custom attributes, if any, will be "stringified" (see "Using custom attributes" in the Storing 4D Write Pro documents in 4D Object fields section).
  • QUERY BY ATTRIBUTE: As specified in the Storing 4D Write Pro documents in 4D Object fields section, the QUERY BY ATTRIBUTE command supports 4D Write Pro attributes (internal and custom) when the documents are stored in Object fields.

Starting with 4D v16, you can can save and reopen 4D Write Pro documents to and from disk without any loss using the native .4wp format.

The .4wp format consists of a zip folder whose name is the document title and whose contents are HTML text and images:

  • HTML text combines regular HTML with 4D expressions (which are not computed) as well as 4D-specific tags,
  • images are stored in a folder with the same name as the document title, next to the HTML file.

Since .4wp documents are based on HTML, they can be imported or opened in any external application supporting HTML.

Note: The 4D Write Pro internal document format is a proprietary HTML extension, compatible with HTML5/XHTML5, but which supports its own subset of HTML/CSS attributes and tags. As a result, only HTML documents exported by 4D Write Pro can be opened by 4D Write Pro without any risk of data loss.

 
 



See also 

Importing 4D Write documents

 
PROPERTIES 

Product: 4D ODBC Pro
Theme: Converting 4D Write documents to 4D Write Pro

 
HISTORY 

 
ARTICLE USAGE

Conversion to 4D v16 ( 4D v16)
Conversion to 4D v16 ( 4D v16.2)
Conversion to 4D v16 ( 4D v16.3)