Primitive text
HOW To write primitive text
-
First you have to decide whether the primitive text should have a border or not. If yes make sure that the button is pressed. Optionally, now you can also define the border type by a click on the button.
-
Click on the text tool .
-
Draw the text frame on the panel surface holding the left mouse button pressed.
-
A white rectangle with a cursor appears.
-
Write your own text.
-
Complete the text input by left-clicking outside the text box in the panel work area.
How to change a text
-
Click on the text.
-
A text border with nine handle points appears.
-
Click on the text once again.
-
A white rectangle with a cursor appears. The text can be edited.
To change the size of the text frame go to the edit mode ("Layout -> Edit Mode" menu). Otherwise the text size will also be changed.
Primitive text in move/scale mode
With one click on the primitive text the graphic object is shown in move/scale mode.
You can move the text field to any place of the panel. Therefore, click on the handle point in the middle of the text frame (the cursor changes to a crossed arrow) and move the object while holding the left mouse button pressed.
Text border
If a primitive text was created with text border its width, style, etc. can be adjusted via the Border property in the property window.
Note that dash color cannot be set for a primitive text.
The color of the border can be specified together with the font color in the property sheet by the attribute Fore color.
The property sheet contains buttons for formatting text, for selecting the width and style of the text border line, and for the background color and filling of the text box (for example, the attributes fore and background color or border).
Alignment and format of the text
The alignment and the format can be changed through the property sheet -> text format.
This opens the "Text Format" window.
In this dialog you can specify the following properties:
-
Datatype: Integer, String, Float, Password or Time.
-
Characters: The number of characters.
-
Number of decimal places and places before the decimal point
-
Alignment: Left, Right, Centered
-
For integer, float numbers and time, you can select the options Empty if Zero (the number will not be shown if it contains zeros only. For the Time datatype this applies to the null time), Leading Zeros or Exponential (only with float values).
For further information see Format string.
In the lower part of the Text format panel the chosen options are shown in the preview window.
You can set the line spacing in the property sheet.
The distance from the text border can also be set in the property sheet.
If you want to present the value of a primitive text in a float variable, use the following code:
dyn_langString ls = this.text;
float f = ls[1]; // Text of the first row
Example
The "text" attribute in the setValue() function has been provided specifically for primitive text. It contains a parameter of the type int, float or string depending on the set format of the field. This parameter is used to set and read the contents (value) of the primitive text. The setValue() function writes a message in the output field according to the status of the variables. The example shows the script for an output field displaying the status of a motor.
main()
{
dpConnect("motor","System1:ExampleDP_Arg1.:_online.._value");
}
motor(string dp, int mod)
{
string
mot;
if (mod== 0)
setValue("PRIMITIVE_TEXT7","text", "Motor off");
/*The
primitive text is PRIMITIVE_TEXT7. If the value of the
ExampleDP_Arg1 DP == 0, "Motor off" is written into the output
field. If the value again is == 1, "Motor chosen" is written to
the output field. In case of other values, "Motor running" is
written to the output field*/
else if (mod== 1)
setValue("PRIMITIVE_TEXT7", "text","Motor chosen");
else
setValue("PRIMITIVE_TEXT7", "text","Motor
running");
}