L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 176

Advertising
background image

L-force | PLC Designer

Visualization

174

DMS 4.1 EN 03/2011 TD29

Formatting of text
Besides the input of a pure text string you also can use formatting sequences to
determine the text display in online mode. A formatting sequence always consists of a
"%" followed by a character. It can be used singly or in combination with a pure text
string.
If you include "%s" in a text string, then this location in online mode will be replaced by
the value of the variable which is specified in the 'Text variables' property 'Text
variable'. If you want to display the instance name of a variable being passed to a
visualization function block, you have to make use of the pragma attribute
'parameterstringof' for an example explaining the details.
Notice that you can use any formatting string conforming with the standard C-library
function 'sprintf', you just have to make sure that it fits to the type of the used
variable.
See here a sample list of strings and arguments:

Character Argument / Output as

d,i

Decimal number

b

Binary number

o

Unsigned octal number (without leading zerol)

x

Unsigned hexadecimal number (without leading 0x)

u

Unsigned decimal number

c

Single character

s

String: This location in online mode will be replaced by the value of the variable which is
specified in the 'Text variables' property 'Text variable'.

f

REAL-values; syntax: %|<alignment><minimal width>.<accuracy>|f
The alignment is defined by a minus-sign (left aligned) or a plus-sign (right aligned, default);
accuracy defines the number of places behind the comma (default: 6); see example below.

Example:
Entry in 'Text' property: Fill level %2.5f mm
Input in the 'Text variable' field (variable of type REAL, providing the fill level value), for
example: plc_prg.fvar1

->

Output in online mode for example: Fill level 32.8999 mm

Note: If you want to get displayed a percent sign % combined with one of the
formatting strings mentioned above, you must enter "%%". For example: Enter
"Rate in %%: %s" to get displayed in online mode "Rate in %: 12" (if the text display
variable currently is "12").

Support of Unicode format can be activated. See the description on Textlists for
detailed information.

Advertising