Update cookies preferences
Promotic

StringFind - method of the Pm object

Description:
Returns the position of the first character of searched text in the string.
Syntax:
Long StringFind(String sValue, String sSearch, Long nStart, [String sParams])
Parameters:
sValue(String) Source string expression.
sSearch(String) Searched string
nStart(Long) The position of character in searched string specifies the start of the search.
The value -2 means the last character of the string (for reverse search).
sParams[optional] (String) Additional search parameters. Entries are in the KeyVal format, for example reverse:1;
reverse:n; - Allows to specify the search direction.
reverse:0; (default) - Forward search direction.
reverse:1; - Backward search direction.
Return value:
-1 - the string was not found
n - the position number of found text (zero-based index)
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.
Example1:
JavaScriptVBScriptSelect and copy to clipboard

var sVal = "PROMOTIC is fun!";
var nRes = Pm.StringFind(sVal, "is", 0);   // nRes contains 9
Example2:
Forward search direction.
JavaScriptVBScriptSelect and copy to clipboard

var iStart = 0;
while (true)
{
iStart = Pm.StringFind("/b1/b2/b3", "/b", iStart);
if (iStart == -1)
{
break;
}
Pm.Debug("iStart=" + iStart);
iStart++;
}
// iStart=0
// iStart=3
// iStart=6
Example3:
Backward search direction.
JavaScriptVBScriptSelect and copy to clipboard

var iStart = -2;
while (true)
{
iStart = Pm.StringFind("/b1/b2/b3", "/b", iStart, "reverse:1;");
if (iStart == -1)
{
break;
}
Pm.Debug("iStart=" + iStart);
iStart--;
}
// iStart=6
// iStart=3
// iStart=0

History:
Pm9.00.27: New option reverse:n; allows to define the search direction.
Pm8.02.01: Created
PROMOTIC 9.0.31 SCADA system documentation MICROSYS, spol. s r.o.

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