Formatting masks
There is implemented formatting of displayed values in the form of a format mask in D2000 System. Basic syntax is usable for Transformation palette. Extended syntax, that replenishes the basic syntax, is usable to display the object in pictures.
Basic syntax
The mask defines the format of displayed numeric value. To create your own formats, you can use the following characters: ##, 0, $, E+, E-, e+, e-.
Character | Meaning |
---|---|
# | Enables the occurrence of a number (the number occurrence is not necessary). If the number is negative, the sign is to be placed on the the first occurrence place of this character. |
0 | Number occurrence required. If the number is not occurred on the given place, it will be replenished by the character "0". |
$ | Rounding-off. |
E+, E- | Exponential form. Exponent is quantified so that the mantissa would be less than 10. |
e+, e- | Exponential form (engineering notation). Exponent is quantified so that it is divisible by 3. |
. | Decimal point. |
To format the exponent, it is possible to use the characters 0 and #. The system will execute automatically the conversion of the format mask according to the following rules:
- after the first character $ from the left, the characters 0 and # are substituted by the character $,
- between the character 0 and the decimal point, the character # is substituted by the character 0.
Entered mask | Mask after conversion |
---|---|
##$$00##$$##00 | ##$$$$$$$$$$$$ |
##00$$##$$##00 | ##00$$$$$$$$$$ |
##00##00$$# | ##000000$$$ |
##0#0.##0### | ##000.000### |
After executing the aforementioned conversion, there are valid the following rules:
- before the character #, placed before the decimal point, there is no occurrence of the character 0,
- before the character #, there is no occurrence of the character $,
- between the character 0 and decimal point, there is no occurrence of the character #
- before the character 0, there is no occurrence of the character $.
The overflow occurs, if the displayed number (or number sign) is longer than the defined mask. After overflow, there is displayed the string of characters "<".
The examples of format mask are shown in the following table.
Object value | Mask | Displayed value |
---|---|---|
129 | {###} | 129 |
129 | {000} | 129 |
129 | {0000} | 0129 |
129 | {000.00} | 129.00 |
129 | {000$} | 0130 |
129 | {# # # #} | 1 2 9 |
1234 | {# ### K} | 1 234 K |
1234 | {#-###} | 1-234 |
1234 | {###} | <<< |
123.6 | {###} | 124 |
123.6 | {###.#} | 123.6 |
123.6 | {###.$} | 124.0 |
-10 | {###} | -10 |
-10 | {# ##} | - 10 |
-10 | {##} | << |
-10 | {# 000} | - 010 |
-10 | {000} | <<< |
-10 | {##E+0} | -1E+1 |
-10 | {##E+00} | -1E+01 |
-10 | {##e+0} | <<<<< |
-10 | {###e+0} | -10E+0 |
The following format marks are used to display the objects, value of which is time type, and the time of object value occurrence.
Mark | Meaning |
---|---|
yyyy or rrrr | Number of year (four-digits). |
yy or rrrr | Last two-digits of year. |
dd | Number of day (two-digits). |
mm | Number of month. |
hh | Hour |
hhh | Number of hours - only for relative time that does not contain a mask for days. |
hhhh | Number of hours - only for relative time that does not contain a mask for days. |
hhhhh | Number of hours - only for relative time that does not contain a mask for days. |
hb, HH | Trading hour - hour in day from 1 to 25. |
mi | Minute |
ss | Second |
mss | Millisecond |
tttt | Name of day in week *. |
ttt | 3-character abbreviation of the day in week *. |
tt | 2-character abbreviation of the day in week *. |
For example, if the object SysTime (System tag) is connected (to view) to the text string:
{hh:mi:ss dd-mm-yyyy},
the text string will display time information in the format:
15:18:36 27-10-1998
If there is used the mask with the shortened format of year "yy", it will be modified on "yyyy". For example, if there is used the mask hh:mi:ss dd-mm-yy, when changing the value, it is modified on hh:mi:ss dd-mm-yyyy by the reason of uniqueness of entering the year (19/20).
Date entry:
- If a mask contains both hh and hb mark, only hh mark will be used.
- In the text entry field the hh mark is highlighted in white and hb mark in light yellow.
Note to days in week:
The names are displayed when using
the transformation palette (I/O tags, user
tags, structured variable items) in pictures, in Browser
and in the functions %TimeToStr and
%TimeToStrEx.
For displaying names of days, you can use the Dictionary
- it will generate a text in particular language instead of the name of day
according to the table:
Day\mask | tt | ttt | tttt |
---|---|---|---|
Monday | {!Mo} | {!Mon} | {!Monday} |
Tuesday | {!Tu} | {!Tue} | {!Tuesday} |
Wednesday | {!We} | {!Wed} | {!Wednesday} |
Thursday | {!Th} | {!Thu} | {!Thursday} |
Friday | {!Fr} | {!Fri} | {!Friday} |
Saturday | {!Sa} | {!Sat} | {!Saturday} |
Sunday | {!Su} | {!Sun} | {!Sunday} |
In the Dictionary, you must define keys (e.g. Mo,Tu,We,Th,Fr,Sa,Su if
you use the mask tt)
and set the language for individual users.
When using the functions
%TimeToStr and
%TimeToStrEx, you must apply the function
%HI_LNG_Translate to the
result.
Extended syntax
In pictures, there is possible to display individual parts of the complex value of D2000 System object - flags. The special text strings (graphic object Text), enclosed between combined brackets "{ }! - format masks, are used to display the values of attributes of linked objects. The mask defines the format of displayed value.
Mask | Displayed attribute of linked object complex value |
---|---|
{A} | Process alarm. |
{D} | Object
description. Note: In pictures, when displaying the object description for structure items, which contain indirect objects, there will be displayed the description of the indirect object instead of the structure description. If the indirect object is not used, there will be displayed the column description. |
{F} | All attributes
(flags) of the object value. Depending on the current value of the flag A
up to P, there will be displayed:
|
{Fflags} | Defined flags
(attributes) of the object value. Unlike the mask {F}, in this case there
will be displayed only values of flags enumerated after the letter F -
flags (e.g. {FACE}). Depending on the current value of the given flag,
there will be displayed:
|
{L} | User name. This mask can be used only for Display mask. |
{N} | Object name. Note: In pictures, when displaying the object name for structure items, which contain indirect objects, there will be displayed the name of the indirect object instead of the structure name. If the indirect object is not used, there will be displayed the structure name, row number and column name. |
{T} | Object value time. |
{Tmask} | Object value time together with the time mask. |
{tmask} | Numeric object value displayed as a time data according to the entered mask for time data. |
{U} | Technical units
of the object. Note: In pictures, when displaying the object technical units for structure items, which contain indirect objects, there will be displayed the technical units of the indirect object instead of technical units of the structure. |
{V} | Object value - the same format as the value displayed in the control window of the object. |
{PV}, {PU}, {PT}, {PTmask}, {Ptmask}, {PF}, {PFflags} | The letter P,
typed in the format mask, will display the previous value of given
attribute. Warning: The letter O, used in format masks, can be used just for the definition of Display mask. |
Combined format masks
The aforementioned text of this topic describes the simple format mask, by means of which it is possible to display the value of one particular attribute of complex object value (e.g. object value, value occurrence time, ...). There can be also used so-called combined format masks, besides simple format masks. These masks, unlike simple ones, display values of several attributes of complex object value.
The combined format mask are defined within the frame of one text string inserted into the picture as graphic object Text.
The examples of combined format mask are shown in the following table.
Mask | Displayed attribute of linked object complex value |
---|---|
{N} {V} | Name and value of the object. |
{V} {U} | Value and technical units of the object. |
{N} {T} {F} | Name, occurrence time and flags of the object. |
Note
- In case that there are defined both the mask for the given attribute (e.g. {V}, {T} ...) and the mask, defining own value format (e.g. {##.#}, {# ### K} ...) within the frame of one combined format mask, there is valid the mask with the value format.
Decimal point in the real numbers
Real numbers display in D2000 HI
The decimal point in the real numbers is represented by a separator (in D2000 HI only) as it is set in the Regional Settings. Both "full stop" and "comma" are supported.
Warning:
- Do not set other mark than "full stop" or "comma" as a decimal point in the Regional Settings.
- In the definition of display mask, there is always used "full stop" to separate the integer part from the fractional one. It is, then, replaced by the mark from the Regional Settings. Therefore, we recommend you to use neither "comma" nor "full stop" for the thousands separator in the masks. For example, if you use the mask: "###,###.###,###", and in the regional settings is "comma" as a decimal point, you will get a strange value, for example "121,652,791,654".
Date and time display
As regards the unformatted outputs of times (e.g. value time), there is mostly used the setting as per the regional settings.
Pridať komentár