CMPSTRING

Concept Link IconSee also Concept Link IconExample

Comparison of two character strings.

WebVue support - Yes.

Syntax

IntVal = CMPSTRING(string1, string2);

Return type: INTEGER.

Execution

The two strings are compared using the ASCII value of the characters. If the string is longer than 1 character, then each character is compared in turn until an inequality is found.

Return

Meaning

-1

string1 is less than string2.

 0

The two strings are equal.

 1

string1 is greater than string2.

Example

DIM Chain1 As Str, Chain2 As Str;
DIM Chain3 As Str, Chain4 As Str;
DIM Res As Integer;
Chain1 = "A";
Chain2 = "B";
Chain3 = "ABCDEG";
Chain4 = "ABDDEF";
Res = CmpString(Chain1, Chain1); ' Res = 0
Res = CmpString(Chain1, Chain2); ' Res = -1
Res = CmpString(Chain2, Chain1); ' Res = 1
Res = CmpString(Chain3, Chain4); ' Res = -1

For further examples, select the Example link above.