Name
CompareStr -- compare two strings (V7.0)
Synopsis
r = CompareStr(s1$, s2$[, casesen, encoding])
Library
string

Function
This function compares s1$ and s2$ and returns how the two strings are related. If s1$ is lexically less than s2$, -1 is returned. If s1$ is lexically greater than s2$, 1 is returned, otherwise, i.e. if the strings are equal, the return value is 0.

The optional argument casesen can be used to specify whether or not the strings should be compared in a case-sensitive manner. This defaults to the global case sensitive default mode set using IgnoreCase(). See IgnoreCase for details.

The optional encoding parameter can be used to set the character encoding to use. This defaults to the default string encoding set using SetDefaultEncoding(). See Character encodings for details.

Note that if you're using Miniwood and you want to have full Unicode support, you will also have to load locale library via the @USING preprocessor command. Otherwise CompareStr() will only support with ASCII characters.

Inputs
s1$
first string to compare
s2$
second string to compare
casesen
optional: True for a case-sensitive comparison, otherwise FALSE; the default is True or whatever default has been set using the IgnoreCase() command
encoding
optional: character encoding to use (defaults to default string encoding)
Results
r
relation of the two strings
Example
DebugPrint(CompareStr("z", "a"))
The code above prints 1 because "z" is lexically greater than "a".

Show TOC