String.Pos

Top  Previous  Next

 

Syntax

function String.Pos(SubStr: string; Str: string): integer

 

Alternative Names

ibec_Pos

 

Description

Tries to locate the given string SubStr in the string Str. This is case sensitive.

 

When found, this returns the character position at which the sub-string is found, starting at position 1. When not found, 0 is returned.

 

To look up additional occurrences, you can use String.PosEx.

 

See also

String.PosEx

 

Example

execute udsblock

as

begin

  strvalue = 'this is a test for String.pos';

  /* the first 'p' is found at position 27 */

  p = String.Pos('p', strvalue);

  

  /* 'x' is not found, 0 is returned */

  p = String.Pos('x', strvalue);

  

  /* skip the first 'a' by starting at position 2 */

  p = String.PosEx('a', 'abab', 2);

end