The formatting rule described here is used for entering how to write value(s) into the text. For example it specifies that the real value should be written with three decimal digits, etc. This formatting text is used in the PROMOTIC application as follows:
If you don't use the characters
% and
\ in the formatting rule, then the result will equal the format text and the values of control variables will not be regarded.
Character
% is used for listing the values of control variables. Characters following the
% define the format of listing:
- Char % specifies listing the % char. Example: "%%" will be "%" after processing
- Char - (minus) specifies alignment of the value to the left
- first string of digits specifies minimal width of the field. Example: "%5d" will be "..123" after processing (periods mean blanks)
- number 0 at the beginning of the first string of digits specifies inserting digits 0 instead of the blank. Example: "%05d" will be "00123" after processing.
- period followed by the second string of digits specifies precision, i.e. maximum number of decimal places. Example: "%6.3f" will be "12.345" after processing, "%.2f" will be "12.34" after processing.
-
character of the data type:
Data type |
Char |
Note |
Example |
Boolean |
'u' |
|
%u |
Byte |
'u' |
|
%u |
Integer |
'd' |
notation in decimal (e.g. "254", "-56" ..) |
%d, %5d, %05d |
Integer |
'x' |
notation in hexadecimal (e.g. "E5F") |
%x, %4x, %04x |
Long |
'ld' |
|
%ld, %7ld, %07d |
Single |
'e'
'f' |
is shown in the form: [-]d.ddde[+-]dd
is shown in the form: [-]dddd.ddd |
%e
%f, %3.4f |
Double |
'le'
'lf' |
is shown in the form: [-]d.ddde[+-]dd
is shown in the form: [-]dddd.ddd |
%le
%lf, %4.7lf |
String |
's' |
|
%s |
Extension of the formatting rule syntax by an
escape sequence:
This extended syntax can be used only when calling the following methods
Pm.StringFormat and
Pm.StringScan.
Sequence |
Char |
ASCII meaning (see The ASCII table) |
\\ |
Char "\" |
Backslash |
\a |
Char with code &H07 |
BEL |
\b |
Char with code &H08 |
BS - Backspace |
\f |
Char with code &H0c |
FF - Formfeed |
\n |
Char with code &H0a |
LF, NL - Linefeed, New Line |
\r |
Char with code &H0d |
CR - Carriage return |
\t |
Char with code &H09 |
HT - Tab, Horizontal Tabulator |
\v |
Char with code &H0b |
VT - Vertical Tabulator |
\xh |
Char with code &Hh |
|
\xhh |
Char with code &Hhh |
|
Note:
HexaString (a text string in hexadecimal) can be used in two ways:
1) Display numbers in hexadecimal, where the higher orders are on the left. It corresponds to the storage in memory of
Big-endian. This is the conversion of a number value into a text string (and vice versa) using a formatting string. To use
HexaString in this way, it is recommended to use the
PmFormat object.
2) Encoding the contents of a memory section of a certain size (e.g. 1B, 2B, 4B, ...) in hexadecimal. Then it depends on how the number is stored in memory. On
Intel and
AMD processors (
x86 or
x64 architecture), the so-called
Little-endian is used, where the lower orders are on the left. To use
HexaString in this way, it is recommended to use the
PmBuffer object, which can handle both
Little-endian and
Big-endian.
Example1:
Let's have the formatting rule:
Temperature=%5d ... Power=%5.2f
and the leading variable (Temperature, the 98 value) is of the Integer type, the next variable (Power, the 34.2345 value) is of the Single type.
The output text will be in the form:
Temperature= 98 ... Power=34.23
Example2:
JavaScriptSelect and copy to clipboard
var str = Pm.StringFormat("New line \\n char 18hexa: \\x18", 1);
is equivalent to the entry
VBScriptSelect and copy to clipboard
Dim str
str = "New line " & Chr(&H0a) & " char 18hexa: " & Chr(&H18)
Now it is correct to pass the parameter without the field for example in the
Pm.StringFormat method:
JavaScriptVBScriptSelect and copy to clipboard
var i = 1;
Pm.Debug(Pm.StringFormat("Value:%d", i));
Dim i
i = 1
Pm.Debug Pm.StringFormat("Value:%d", i)