uniStrPos()

Returns the position of a string within another.

Synopsis

int uniStrPos(string s, string searchstr[, int startPos = 0]);

Parameters

Parameter Description
s String to be examined
searchstr String searched for
startPos Optional parameter. Start position for the search in the string.

Return value

Position number, if searchstr is not found within s -1, or in the event of an error -2 is returned.

Errors

Missing/incorrect arguments

Description

Returns the position (character position) of the string searchstr (the first occurrence of search) within the string s. For the first character of s it is equal to zero, for the second 1 etc. If searchstr is not found within s, -1, in the event of an error -2, is returned.

Example

main()
{
  /*Returns the position of a string within another. */
  string SString = "This is a search for the position of a
  string";
  string SeString = "string";
  int starPos = 0;
  int c = uniStrPos(SString, SeString,starPos);
  DebugN("The position of the string:", c);
}

Assignment

Strings

Availability

CTRL