StringSplit - method of the Pm object

Returns a 1-dimensional array of substrings (zero-based index).
Array StringSplit(String sString, String sDelimiter, [String sParams])
sString(String) Source string expression.
sDelimiter(String) Separator, i.e. text used to identify substring boundaries.
single character string - This character will be searched in the source string (in sString) and according to that, the source will be divided into substring array.
The most commonly used separators ";" (semicolon), ":" (colon), " " (space), etc.
"" - Source string (sString) is separated into individual characters. It means that the length of the returned array will be the same as source string.
"#nl" - (new line) Source string (sString) is separated to individual rows.
"#ws" - (white space) Source string (sString) is separated to individual words. It means that the characters like "space", "new line", "tab", etc. will be used as separators and will not be present in the output substrings.
sParams[optional] (String) Additional parameters. Entries are in the KeyVal format, for example count:2;empty:0;
count:n; - The maximum length of returned array.
If the parameter is not set (or the value is -1), then each separator is used for separation flag. It means that all substrings are saved into the array.
If n is positive number, then the method returns the maximum number of substrings
If there are less substrings, then the returned array is smaller.
If there are more substrings, then the substring at the end are not saved into the array.
empty:n; - Specifies the way the empty string after the last separator is returned in the array of values.
empty:0; (default) - If the string ends with the separator, then the last array item will be an empty string.
empty:1; - If the string ends with the separator, then the empty string is NOT saved to the end of the array.
Return value:
PmArray object for JavaScript or Array data type for VBScript.
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.
JavaScriptVBScriptSelect and copy to clipboard

var sValue = "Temperature=45;Pressure=1015;Power=569;";

var arr1 = Pm.StringSplit(sValue, ";", "empty:1;");
// arr1.GetItem(0) contains "Temperature=45"
// arr1.GetItem(1) contains "Pressure=1015"
// arr1.GetItem(2) contains "Power=569"
// arr1.GetItem(3) does not exist because the empty string after the last semicolon is not saved ("empty:1;" is set)

var arr2 = Pm.StringSplit(arr1.GetItem(0), "=");
arr2 = Pm.StringSplit(arr1.GetItem(0), "=");
// arr2.GetItem(0) contains "Temperature"
// arr2.GetItem(1) contains "45"

Pm8.02.01: Created
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
- Pm
- Abs
- Cos
- E
- Exp
- LN2
- PI
- Pow
- Sin
- StringSplit
- Tan
© MICROSYS, spol. s r.o.