StringFormat - method of the Pm object
Description:
Writing an array of values into the string according to the formatting rule.
This method is obsolete (but functional) and it is better to use the
PmFormat.Format method.
Syntax:
String StringFormat(String sFormat, Variant vParams)
Parameters:
sFormat | (String) Formatting rule written in the C language convention. See C language formatting rule. |
vParams | (Variant) The parameter can be:
- Elementar data type (Integer, Double, String) if the sFormat contains single value format, or
- Array of values if the sFormat contains multi value format. |
---|
Note:
This method is functional also in
Macro expression $.expr and in the
onDraw event of the
PmgCanvas object.
This method is also functional in
Web panels.
HexaString (a text string in hexadecimal format) 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 the 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:
Formatting a single value of the Integer type for hexadecimal view
JavaScriptVBScriptSelect and copy to clipboard
var nVal = 1024;
var sVal = Pm.StringFormat("%05x", nVal);
Dim nVal, sVal
nVal = 1024
sVal = Pm.StringFormat("%05x", nVal)
Example2:
Formatting multiple values simultaneously
JavaScriptVBScriptSelect and copy to clipboard
var n1 = 11.2;
var n2 = 1002.4;
var aData = Pm.CreatePmArray().Array1(n1, n2);
var sVal = Pm.StringFormat("Temperature=%3.2f, Pressure=%5.1f", aData);
Dim n1, n2, aData, sVal
n1 = 11.2
n2 = 1002.4
aData = Array(n1, n2)
sVal = Pm.StringFormat("Temperature=%3.2f, Pressure=%5.1f", aData)