Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to procedurally place text in a 4D Write area and change the text property
Published On: April 3, 2002

Compatibility: 6.5.x and 6.7.x
Platforms: Windows and Mac OS

Suppose you are procedurally placing text into a 4D Write area and want to set different attributes to the text depending on certain criteria. To do this, you need to be know exactly where the text starts and where it ends.

Here is an example:

Violet:=WR RGB to color (61952;2048;33792)


WR INSERT TEXT (area1;$TextVariable)

WR SET SELECTION (area1;0;$sizeOfString)

WR SET TEXT PROPERTY (Area1;wr font size ;12)

WR SET TEXT PROPERTY (Area1;wr text color ;Violet)

WR SET TEXT PROPERTY (Area1;wr bold ;1)

WR SET TEXT PROPERTY (Area1;wr italic ;1)

In this simple example, the text was simply placed where the cursor is located (first line). You can use WR SET CURSOR POSITION and specify exactly where to place the cursor. Because you know exactly how many characters are in the string, using WR SET SELECTION, you can select the appropriate text. From there, it is very simple to set the attributes of your choice.