The output text of an element can display the value of a variable by means of a placeholder (%) with a format definition. When the text is displayed, the value of the variable is inserted instead of the placeholder. The data type in the format definition and of the variable have to be identical.
The displayed string is listed in the element property. The variable is listed in the Text variable property.
Visualization users can specify a text in an element, in which the text, for example, is stored and displayed as a text output variable. The user input has to correspond to the input format. The data type of the text output variable has to correspond to the data type which is defined for the input format.
The format definition for the input text is located in the Input configuration dialog, in Text input, in the Write Variable input action. The variable is listed in the Text variable property.
The format definition for an integer has the following format:
% <flags><minimum number of digits><type>
Recommended data types: BYTE | WORD | DWORD | LWORD | SINT | USINT | INT | UINT | DINT | UDINT | LINT | ULINT
|
Syntax |
Example |
Description |
Example in Visualization |
|---|---|---|---|
|
<flags> |
Optional and combinable |
Code: Text variable property: |
|
|
|
|
Alignment left-justified, with respect to the minimum width of the number (specified in minimum number of digits) |
Text property: |
|
|
|
Output always with a sign |
Text property: Output: |
|
|
|
Places are filled with a 0 until the minimum number of places (including the sign) is reached |
Text property: |
|
<minimum number of digits> |
|
Optional Minimum number of places |
|
Syntax |
Example |
Description |
Example in Visualization |
|---|---|---|---|
|
<type> |
Required |
||
|
|
|
Output as an integer decimal number |
Code: Text property: Text variable property: Output: |
|
|
Code: Text property: Text variable property: Output: |
||
|
|
|
Output as unsigned, integer binary number without a prefix |
Code: Text property: Text variable property: Output: |
|
|
|
Output as unsigned, integer octal number without a prefix |
Code: Text property: Text variable property: Output: |
|
|
|
Output as an unsigned 32-bit hexadecimal number with the digits a–f (lowercase) without a prefix and without a separator |
Code: Text property: Text variable property: Output: |
|
|
|
Output as an unsigned 32-bit hexadecimal number with the digits A–F (uppercase) without a prefix and without a separator |
Code: Text property: Text variable property: Output: |
|
|
|
Output as an unsigned 64-bit hexadecimal number with the digits a–f (lowercase) without a prefix and without a separator Note: Recommended data types: |
Code: Text property: Text variable property: Output: |
|
|
|
Output as an unsigned 64-bit hexadecimal number with the digits A–F (uppercase) without a prefix and without a separator Recommended data types: |
Code: Text property: Text variable property: Output: |
|
|
|
Output as an unsigned integer decimal number Recommended data types: |
Code: Text property: Text variable property: Output: |
Floating-point numbers can be displayed as a decimal number in fixed-point notation. The format definition for this has the following format:
% <flags><minimum number of digits> . <accuracy> f
Recommended data types for this kind of placeholder variable: REAL | LREAL
|
Syntax |
Example |
Description |
Example in Visualization |
|---|---|---|---|
|
<flags> |
Optional and combinable |
||
|
|
|
Alignment left-justified, with respect to the minimum number of digits |
|
|
|
|
Always with a sign, also for positive numbers |
Code: Text property: Text variable property: Output: |
|
|
|
Places are filled with a 0 until the minimum number of places (including the sign and decimal point) is reached |
Code: Text property: Text variable property: Output: |
|
<minimum number of digits> . <accuracy> |
Optional When not specified, the number is output in standard format 1.6 |
||
|
<minimum number of digits> |
|
Minimum number of places including the sign and decimal point Example: 12 |
Code: Text property: Text variable property: Output: |
|
<accuracy> |
|
Accuracy in places and the decimal point Example: 3 |
Code: Text property: Text variable property: Output: |
|
|
|
Required Format identifier for decimal display with the decimal point |
Code: Text property: Text variable property: Output: |
Floating-point numbers can be displayed in standardized exponential notation with base 10. The format definition for exponential notation has the following format:
% <flags><minimum number of digits> . <accuracy><type>
Recommended data types for this kind of placeholder variable: REAL | LREAL
|
Syntax |
Example |
Description |
Example in Visualization |
|---|---|---|---|
|
<flags> |
Optional and combinable |
||
|
|
|
Alignment left-justified, with respect to the minimum number of digits |
|
|
|
|
Always with a sign, also for positive numbers |
Code: Text property: Text variable property: Output: |
|
|
|
Places are filled with a 0 until the minimum number of places (including the sign and decimal point) is reached |
Code: Text property: Text variable property: Output: |
|
<minimum number of digits> . <accuracy> |
Optional When not specified, the mantissa is output in standard format 1.6 |
||
|
<minimum number of digits> |
|
Minimum number of places, including the sign (for mantissa and exponent), decimal point, and exponents ( Example: 12 |
Code: Text property: Text variable property: Output: |
|
<accuracy> |
|
Accuracy of the mantissa in places and the decimal point Example: 3 |
Code: Text property: Text variable property: Output: |
|
<type> |
Required |
||
|
|
|
Display with |
Code: Text property: Text variable property: Output: |
|
|
|
Display with |
Code: Text property: Text variable property: Output: |
|
Compatibility Notice |
|---|---|
|
In order to get the usual display, in V3.5 SP17 and higher, as a rule three digits are used for the output of fractions of a second (ms/µs/ns). Example: In |
If the output text in the element property contains the placeholder %t with an identification for a time unit, then a time, a time duration, or a time interval is output. The placeholder variable is assigned in the Text variable property.
The placeholder for a time per time unit has the following format:
%t[ <text><time in unit><text> ]
Recommended data types: TIME, LTIME
|
Syntax |
Example |
Description |
Example in Visualization |
|---|---|---|---|
|
<time in unit> |
Required Identification for a time unit Filters from the time value the complete number of the specified time unit (days, hours, minutes, seconds, milliseconds) For 64-bit time values, also microseconds and nanoseconds |
||
|
Valid for the following examples: Code: Text variable property: |
|||
|
|
|
Number of days, without a prepended zero |
Text property: Output: |
|
|
|
Number of whole days, with a prepended zero |
Text property: Output: |
|
|
|
Number of hours (1–24) |
Text property: Output: |
|
|
|
Number of hours (01–24) |
Text property: Output: |
|
|
|
Number of hours (1–12) |
Text property: Output: |
|
|
|
Number of hours (01–12) |
Text property: Output: |
|
|
|
Number of minutes (0–59), without leading zero |
Text property: Output: |
|
|
|
Number of minutes (00–59), with leading zero |
Text property: Output: |
|
|
|
Number of seconds (00–59), without leading zero |
Text property: Output: |
|
|
|
Number of seconds (00–59), with leading zero |
Text property: Output: |
|
|
|
Number of fractional seconds, in milliseconds (0–999) |
Text property: Output: |
|
|
|
Number of fractional seconds, in microseconds (0–999) Only for data type |
Text property: Output: Note: Overflow is permitted in the greatest time unit of a definition. |
|
|
|
Number of fractional seconds, in nanoseconds (0–999) Only for data type |
Text property: Output: Note: Overflow is permitted in the greatest time unit of a definition. |
|
<text> |
|
Optional Strings, which are specified inside brackets, are included in the output Note: If a string should be output, which corresponds to an identification for a time unit or which contains identifications for time units, then the string has to be enclosed in single straight quotation marks. |
Text property: Output: Text property: Output: |
Inside the brackets, identifications for time units can occur any number of times and can be interchanged with any strings.
|
Syntax |
Example |
Description |
Example in Visualization |
|---|---|---|---|
|
|
Time format for all time units, with the usual separator in between |
Text property: Output: |
|
|
|
Format with additional strings which should be output, without considering the identifications for time units These kinds of strings are enclosed in simple straight quotation marks. |
Text property: Output: |
Recommended data types: TIME, LTIME
In the format definition, the time duration <time in unit> can be identified with the decimal place identification <number of decimal places>. The result is that the time duration is formatted as a decimal number (with decimal places) in the specified time unit. That is possible for the following time formats: HH | H | hh | h| mm | m | ss | s | ms |us | ns. This can be useful for user input.
The placeholder for a time span as a decimal number has the following format:
%t[ <time in unit><number of decimal places>]
|
Syntax |
Example |
Description |
Example in Visualization |
|---|---|---|---|
|
<time in unit> |
Required Identification of a time unit which formats the time value in the specified time unit (days, hours, minutes, seconds, milliseconds) as a decimal number For 64-bit time values, also microseconds and nanoseconds |
||
|
<number of decimal places> |
Required Maximum number of decimal places ( Note: Even if decimal places are not desired for the input or display, at least the number |
||
|
The requirements apply for the following examples: Code: Text variable property: |
|||
|
|
|
Time value (in hours) as a decimal number Example: 4 |
Text property: User input: Time value: |
|
|
|
Time value (in minutes) as a decimal number Example: 2 |
User input: Time value |
|
|
|
Time value (in seconds) as a decimal number Example: 3 |
User input: Time value |
|
|
Example: 0 |
User input: Time value |
|
|
|
|
Time value (in milliseconds) as a decimal number Example: 3 |
User input: Time value |
|
|
|
Time value (in microseconds) as a decimal number Example: 3 |
User input: Time value |
|
|
|
Time value (in nanoseconds) as a decimal number Example: 0 |
User input: Time value |
If a variable is not assigned to a placeholder with a format definition, then the system time is output.
|
Syntax |
Example |
Description |
Example in Visualization |
|---|---|---|---|
|
|
|
Output of the current system time Requirement: No variable is specified below the Text variable property. |
Text property: Text variable property: blank Output: |
|
|
|
Optional Output of the offset of the local system time as universal time (UTC) |
Text property: Depending on the UTC variable
|
|
Tip |
|---|---|
|
You can programmatically switch the local time zone of the system time to universal time (UTC). When the variable For the display of date and time values, you can extend the respective format string with the time zone code |
|
Compatibility Notice |
|---|---|
|
In order to get the usual display, in V3.5 SP17 and higher, as a rule three digits are used for the output of fractions of a second (ms/µs/ns). Example: In |
Recommended data types for date and time definitions: DATE, DATE_AND_TIME, DT, LDATE, LDATE_AND_TIME, LDT, LTOD, TIME_OF_DAY, TOD
By default, the names of the days and months are displayed in English. When localized texts are used, the System text list has to be supplemented. This text list is automatically created in the POUs view when the %t placeholder is used. The English terms have to be used as the IDs here. The localization can be done for both the abbreviated names and full names.
The format string for a date and time definition has the following format:
%t[ <date and time unit> ]
|
Syntax |
Example |
Description |
Example in Visualization |
|---|---|---|---|
|
<date and time unit> |
Required Identification for date and time units Filters from the time value (data type: date and time) the value for the specified unit (year, month, day, hour, minute, milliseconds) For 64-bit date and time values, also microseconds and nanoseconds |
||
|
|
|
Year with century |
Code: Text property: Text variable property: Output: |
|
|
|
Year without century (00–99) |
Code: Text property: Text variable property: Output: |
|
|
|
Year without century (0–99) |
Code: Text property: Text variable property: Output: |
|
|
|
Month as full name |
Code: Text property: Text variable property: Output: |
|
|
|
Month as abbreviated name |
Code: Text property: Text variable property: Output: |
|
|
|
Month as number (01–12) |
Code: Text property: Text variable property: Output: |
|
|
|
Month as number (1–12) |
Code: Text property: Text variable property: Output: |
|
|
|
Day of week as number (1 = Monday – 7 = Sunday) |
Code: Text property: Text variable property: Output: |
|
|
|
Day of week as full name |
Code: Text property: Text variable property: Output: |
|
|
|
Day of week as abbreviated name |
Code: Text property: Text variable property: Output: |
|
|
|
Day of month as number (01–31) |
Code: Text property: Text variable property: Output: |
|
|
|
Day of month as number (1–31) |
Code: Text property: Text variable property: Output: |
|
|
|
Day of year as number (001–366) |
Code: Text property: Text variable property: Output: |
|
|
|
Hour in 24-hour format (00–23) Example
|
Code: Text property: Text variable property: Output: |
|
|
|
Hour in 12-hour format (01–12) Example
|
Code: Text property: Text variable property: Output: |
|
|
|
Abbreviation A or P in 12-hour format A for P for Example
|
Code: Text property: Text variable property: Output: |
|
|
|
Abbreviation AM or PM in 12-hour format AM for PM for Example
|
Code: Text property: Text variable property: Output: |
Inside the brackets, identifications for date and time units can occur any number of times and can be interchanged with any strings.
|
Syntax |
Example |
Description |
Example in Visualization |
|---|---|---|---|
|
|
Date and day of the week with separators in between |
Code: Text property: Text variable property: Output: |
|
|
|
Time of day |
Code: Text property: Text variable property: Output: |
|
|
|
If strings should be output which correspond to a format definition, then these have to be represented in single straight quotation marks. |
Text property: Output: |
Recommended data types of the placeholder variable: STRING, WSTRING
The format definition for strings and strings have the following format:
% <type>
|
Syntax |
Example |
Description |
Example in Visualization |
|---|---|---|---|
|
<type> |
|||
|
|
|
Output of single character in ASCII character set |
Code: Text property: Text variable property: Output: |
|
|
|
Output of string Recommended data types: |
Code: Text property: Text variable property: Output: When UTF-8 encoding is enabled for the For more information, see: Dialog: Project Settings – Compile options |
Format definition for output of a percent sign
|
Syntax |
Example |
Description |
Example in Visualization |
|---|---|---|---|
|
|
|
Output of the percent sign |
With a placeholder variable: Code: Text property: Text variable property: Output: |
|
Text property: Output: |