KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Setting Write Pro Attributes
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: September 7, 2020

4D Write Pro documents can contain many parts that can be referenced by objects. To make modifications or see the current value to these parts typically the WP SET ATTRIBUTES or WP GET ATTRIBUTES commands can be used respectively. There is an alternative way to access these attributes. As mentioned the parts can be referenced as objects and as such object notation can be used to dirrectly access the attributes.

For example for the font property, to set and get the font of a text range the method using the 4D commands would look like:

WP GET ATTRIBUTES(wpTextRange_ob;wk font;$resultFont_t)
WP SET ATTRIBUTES(wpTextRange_ob;wk font;$newFont_t)

The constant wk font actually contains "font", using object notation, the method would look like:
$resultFont_t:=wpTextRange_ob[wk font]
wpTextRange_ob[wk font]:=$newFont_t

Another way is using dot notation, however there won't be benefit from autocomplete to confirm the attribute name:
$resultFont_t:=wpTextRange_ob.font
wpTextRange_ob.font:=$newFont_t

These are three possible ways to set attributes to parts of a 4D Write Pro document.