StringSplit - method of object Pm

Returns a 1-dimensional array of substrings (zero-based index).
StringSplit(sString As String, sDelimiter As String, [sParams As String]) As Array
aArray = Pm.StringSplit(sString, sDelimiter[, 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 lenght 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 format KeyVal, for example count:2;empty:0;
count:n; - The maximum lenght of returned array.
If the parameter is not set (or the value is -1), then each separator is used for separation. It means that all substrings are saved into the array.
If the parameter 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.
The method can also be called in the graphic item events for Web panels.

The method is functional also in Macro expression $.expr and in the onDraw event of the PmiCanvas graphic item.

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) doesn't 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"
PROMOTIC 8.3.30 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.Tavičská 845/21 703 00 Ostrava-Vítkovice