KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Consolidating Styled Text from Multiple 4D Write Documents
PRODUCT: 4D Write | VERSION: 2004.7 | PLATFORM: Mac & Win
Published On: February 20, 2008

WR Get styled text and WR INSERT STYLED TEXT can be used to programmatically consolidate text from multiple 4D Write areas into one 4D Write area without losing the text formatting. In the following code this is used to print all of the 4D Write documents stored in a BLOB field (PluginArea1_ in the example) in a table ([Table 1] in the example) as one 4D Write area. This can be useful if they are all short documents and a developer does not want to print each document on a separate page.

`create offscreen area for printing
$Print:=WR New offscreen area

`cycle through all records in [Table 1] for 4D Write BLOBS
ALL RECORDS([Table 1])

For ($I;1;Records in selection([Table 1]))
   `create a temporary offscreen area to store the 4D Write document
   $Temp:=WR New offscreen area
   WR BLOB TO AREA ($Temp;[Table 1]PluginArea1_)

   `select all the text in the 4D Write area and put it in $BLOB
   $char:=WR Count ($Temp;0)
   WR SET SELECTION ($Temp;0;$char)
   $BLOB:=WR Get styled text ($Temp)

   `set the insertion point in the printing area and insert text
   $char:=WR Count ($Print;0)
   WR SET SELECTION ($Print;$char;$char)
   WR INSERT STYLED TEXT ($Print;$BLOB)

   `clear the temporary area and move on to the next record
   WR DELETE OFFSCREEN AREA ($Temp)
   NEXT RECORD([Table 1])
End for

`print the printing area and clear it
WR PRINT ($Print)
WR DELETE OFFSCREEN AREA ($Print)