KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Managing Carriage Returns in 4D Write Pro Formulas
PRODUCT: 4D | VERSION: 18 R | PLATFORM: Mac & Win
Published On: January 25, 2021

With 4D Write Pro, all carriage return characters inside formulas or expressions are interpreted as line breaks. This differs from the previous behavior of 4D Write, where carriage returns were interpreted as paragraph breaks.

Line breaks start a new line in the same paragraph (line begins at "Paragraph Left Margin")
Paragarph breaks begin a line in a new paragraph (line begins at "First Line Indent")



Becuase of this, working with Write Pro formulas that contain carriage returns may produce undesired alignment. As of v18R4, a new document property has been created to manage how these carriage returns should be interpreted. The developer can set whether carriage returns in formulas are to be interpreted as a line break or a paragraph break with WP SET ATTRIBUTES.

To interpreted them as paragraph breaks, run the following code. To revert and interpret them as line breaks, set the attribute to False.

WP SET ATTRIBUTES(WParea;wk break paragraphs in formulas;True)

The following examples show the different results based on how the carriage return is interpreted when inserting the formula below to the Write Pro document.

Example Letter Template where the carriage return creates a paragraph break.


Example Letter Template where the carriage return creates a line break.


Formula containing carrirage returns
C_OBJECT($o)
$o:=New object
$o.formula:=Formula(String($o.name+"\r"+$o.address+"\r"+$o.state+", "+$o.city+", "+$o.zip+"\r\r"+$o.date))
$o.name:="[Your Name]"
$o.address:="[Street Address]"
$o.state:="[State"
$o.city:="City"
$o.zip:="Zip]"
$o.date:="[Today's Date]"
WP INSERT FORMULA(WParea;$o.formula;wk replace)