KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Programmatically Styling Appended text in Write Pro Tables
PRODUCT: 4D Write Pro | VERSION: 20 | PLATFORM: Mac & Win
Published On: January 6, 2025

A developer may want to set the style of text they are appending to text within a cell of a write pro table. Perhaps to bring attention to the new text and show that it has been changed. It can be done with the following code given that the developer already has a table created.

$cell:=WP Table get cells($table; 1; 1; 1; 1)
$range:=WP Text range($cell; wk start text; wk end text)
$range:=WP Text range($range; $range.start; $range.end-1)

//store the current end of the range
$temp:=$range.end

//append text to the current range
WP SET TEXT($range; " Newly appended text."; wk append)

//new range that is only the range of the new text
$range:=WP Text range($range; $temp; $range.end)

//set attributes to the selected range
WP SET ATTRIBUTES($range; wk text color; "green")