Strnicmp Function

Action

Compares lexicographically the first nCount characters in two strings without regard to case-sensitivity. For case-sensitive string comparison use the Strncmp function.

Include file

Kernel.bdh

Syntax

Strnicmp(in sString1 : string,
         in sString2 : string,
         in nCount : number): number;

Return value

  • value < 0. sString1 is less than sString2

  • value = 0. sString1 is identical to sString2

  • value > 0. sString1 is greater than sString2

Parameter Description
sString1 Defines the first string to compare
sString2 Defines the second string to compare
nCount Defines the number of characters to compare

Example

dcltrans
  transaction TStrnicmp
  var
    sString1, sString2 : string;
    nResult1, nResult2 : number;
  begin
    sString1 := "HELLO beautiful world!";
    sString2 := "Hello beautiful lady!";
    write("string1 = "); write(sString1); writeln;
    write("string2 = "); write(sString2); writeln;
    nResult1 := Strnicmp(sString1, sString2,15);
    nResult2 := Strnicmp(sString1, sString2, 20);
    if nResult1 = 0 then
      write("first 15 characters are equal"); writeln;
    else
      write("first 15 characters are not equal"); writeln;
    end;
    if nResult2 = 0 then
      write("first 20 characters are equal"); writeln;
    else
      write("first 20 characters are not equal"); writeln;
    end;
  end TStrnicmp;

Output

string1 = HELLO beautiful world!
string2 = Hello beautiful lady!
first 15 characters are equal
first 20 characters are not equal