JCL Help:AnsiCompareNaturalText
JCL Help: AnsiCompareNaturalText Function
Search in JCL Help
Search in all projects
Summary
Compares strings based on the current locale with case insensitivity and using a 'natural order' algorithm.
Pascal
function AnsiCompareNaturalText(const S1: AnsiString; const S2: AnsiString): SizeInt;
Parameters
Parameters | Description |
const S1: AnsiString | First string to compare. |
const S2: AnsiString | Second string to compare. |
Return Value
0
if S1 is identical to S2 - or -a negative value
if S1 is less than S2 - or -a positive value
if S1 is greater than S2
Description
AnsiCompareNaturalText implements a case-insensitive, 'natural' comparison between the two supplied strings. It performs identical to the AnsiCompareText function but compares number components numerically, instead of alphabetically.
Leading spaces are ignored when comparing numbers, but leading zeroes aren't. This gives more sensible order when comparing and sorting fractional numbers.
The table below shows the behaviour of both AnsiCompareNaturalText and AnsiCompareText:
S1 | S2 | AnsiCompareNaturalText | AnsiCompareText |
Delphi 5 | Delphi 2005 | negative | positive |
Delphi 5 | Delphi 2005 | negative | negative |
Delphi 5 | Delphi 6 | negative | negative |
Delphi 5 | Delphi 6 | negative | positive |
Delphi Highlander | Delphi 2005 | positive | positive |
Delphi Highlander | Delphi Highlander | positive | positive |
Foobar v0.9.4 | Foobar v0.10.3 | negative | positive |
Foobar v0.9.4 | Foobar V0.9.4 | zero | zero |
0002 | 1 | negative | negative |
1.5 | 1.06 | positive | negative |
0 | -5 | positive | positive |
-5 | +2 | negative | positive |
About
Unit
Donator
Marcel Bestebroer
Contribute to this help topic
This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page