C language string format specification

The formatting text described here is used for definition how to write value(s) into the text. For example it is possible to define that the real value should be written with three decimal digits, etc. This formatting text is used in the PROMOTIC system as follows:
- in methods Pm.StringFormat and Pm.StringScan.
- in Value format type configurator of the PmiText graphic item.
- in Value format type configurator of the PmiWEdit graphic item.
If you don't use the characters % and \ in the format text, 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. Chars following the % define the format of listing:

- Char % indicates listing the % char. Example: "%%" will be "%" after processing
- Char - (minus) indicates the left alignment of the value
- first string of numbers indicates 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 numbers indicates inserting number 0 instead of the blank. Example: "%05d" will be "00123" after processing.
- period followed by the second string of numbers indicates accuracy, i.e. the maximum number of decimal places. Example: "%6.3f" will be "12.345" after processing, "%.2f" will be "12.34" after processing.
- chars of the data type:
Data type Char NoteExample
Boolean 'u'   %u
Byte 'u'   %u
Integer 'd' decimal notation (e.g. "254", "-56" ..) %d, %5d, %05d
Integer 'x' hexadecimal notation (e.g. "E5F") %x, %4x, %04x
Long 'ld'   %ld, %7ld, %07d
is shown in the form: [-]d.ddde[+-]dd
is shown in the form: [-]dddd.ddd
%f, %3.4f
is shown in the form: [-]d.ddde[+-]dd
is shown in the form: [-]dddd.ddd
%lf, %4.7lf
String 's'   %s
Extension of the format text 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 Tabelator
\v Char with code &H0b VT - Vertical Tabelator
\xh Char with code &Hh  
\xhh Char with code &Hhh  
Let's have the format rule:
Temperature=%5d ... Power=%5.2f

and the leading variable (Temperature, value 98) is of Integer type, the next variable (Power, value 34.2345) is of Float type.

The output text will be in the form:

Temperature= 98 ... Power=34.23
str = Pm.StringFormat("New line \n char 18hexa: \x18", 1)
is equivalent to the entry
str = "New line " & Chr(&H0a) & " char 18hexa: " & Chr(&H18)
Now it is correct to pass the parameter without the field for example to the Pm.StringFormat method:
Dim i
Pm.Debug Pm.StringFormat("Value:%i", i)
PROMOTIC 8.3.19 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice