Strchr Function

Action

Searches for the first occurrence of a character in a string.

Include file

Kernel.bdh

Syntax

Strchr( in sString    : string,
        in nCharacter : number ): string;

Return value

String beginning with the first occurrence of the defined character. If the character is not found, the returned string is empty.

Parameter Description
sString Defines the string to search in
nCharacter Defines the character to search

Example

dcltrans
  transaction TStrchr
  var
    sString, sPart : string;
    nChar          : number;
  begin
    sString := "Hello world!";
    nChar := ord('w');
    write("string = "); write(sString); writeln;
    write("char = "); write(chr(nChar)); writeln;

    sPart := Strchr(sString, nChar);
    write("part = "); write(sPart); writeln;
  end TStrchr;

Output

string = Hello world!
char = w
part = world!