You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Compares two values as strings.

Syntax

Result = SRP_String("Compare", String1, String2, IgnoreCase)

Parameters

ParameterDescription
String1One of the two strings to be compared. (REQUIRED)
String2The other string to be compared. (REQUIRED)
IgnoreCaseIndicates whether the comparison is case-sensitive or case-insensitive.  (OPTIONAL)

Returns

Returns an integer less than zero if String1 is less than String 2. Returns an integer greater than zero if String1 is greater than String2. Returns 0 if the strings are equal.

Remarks

The Compare service compares two variables as strings. When you use BASIC+ comparison operators, the variables' contents will be converted into numbers if possible. The Compare service, on the other hand, always does a character by character comparison.

Example

Str1 = "27"
Str2 = "27."

// In BASIC+, these are equal
If Str1 = Str2 then
    Ans = "Equal Value"
end else
    Ans = "Not Equal Value"
end

// Using the Compare service, these strings are not equal
If SRP_String("Compare", Str1, Str2) = 0 then
    Ans = "Equal Strings"
end else
    Ans = "Not Equal Strings"
end

// Case sensitive comparison returns 0
Ans = SRP_String("Compare", "HELLO", "hello", No$)

// Case insensitive comparison returns 1
Ans = SRP_String("Compare", "HELLO", "hello", Yes$)

See Also



  • No labels