StrCompare

Navigation:  Appendices > Macro Language > Built-in Functions > All Functions (Alphabetical) >

StrCompare

Previous pageReturn to chapter overviewNext page

int = StrCompare(sOne, sTwo, bCaseSensitive)

 

This macro function compares two strings and returns -1 if sOne is "less" than sTwo, 0 if they are both equal, and +1 if sOne is "more" than sTwo. By more and less, we mean the position of each string in an alphabetical listing. This function is particularly useful to sort strings.

 

StrCompare('A', 'Z', false);       // returns -1

StrCompare('AAA', 'aaaa', false); // returns -1

StrCompare('AAAB', 'aaaa', false); // returns +1

StrCompare('A', 'a', false);       // returns  0

StrCompare('Aaaa', 'aaaa', false); // returns  0

 

The boolean parameter, bCaseSensitive, determines if the comparison is to take note of uppercase and lowercase letters.

 

StrCompare('A', 'Z', true);       // returns -1

StrCompare('AAA', 'aaaa', true); // returns +1  <---

StrCompare('AAAB', 'aaaa', true); // returns +1

StrCompare('A', 'a', true);       // returns +1  <---

StrCompare('Aaaa', 'aaaa', true); // returns +1  <---

 

Note that the sort order is determined by the regional settings of Windows on your PC; this has an impact for strings which contain letters such as å æ ø.


Topic 137200 updated on 05-Mar-2002.
Topic URL: http://www.qppstudio.net/webhelp/index.html?strcompare.htm