For some reason I had forgotten to include this in the previous update. Im not sure why. It could be that I found a problem with it.. Ive tested for obvious bugs (such as stack overrun, etc) but cant find anything glaringly wrong with it. Since I use this function a lot (but not all features!) and since it is mentioned in some subroutines Ive put in the GOTO section, I include it now. Please let me know if you discover anything that is not as is should be!


This command uses the various internal comparison types to perform a
comparison of two strings. The bulk of the text below comes from the
QDOS/SMS Reference Manual v. 4.4 10/06/2018, Section 16 - 19. This may not
apply to Minerva, which has its own ideas on string comparison!

        result% = CMP%(str1$, str$ [, comptype% [,table]])

        result% is
                -1 for str1$ < str2$
                 0 for str1$ = str2$
                 1 for str1$ > str2$

        comptype% is 0..3, as described below
                 Optional (default = 0), unless table is used

   and  the optional table parameter, which specifies the address of a
        256 byte translation table. (See below.)

Order of Strings

Since comparison may be used to sort strings into order as well as checking
for equality or equivalence, the order must be well defined. A form of
dictionary order is attempted - this will require to be modified for foreign
character sets.

Space is the first character. Punctuation is in ASCII order (except "." which
is the last). All punctuation is defined to be before all letters or digits
(e.g. A. before AA. ). Optionally, embedded numbers may be taken in numerical
order (e.g. Case5A before Case10A, and also Case5.10 before Case5.5).

All digits or numbers are defined to be before all letters (e.g. bat1 before
bath1). An upper case letter comes before the corresponding lower case
letter but after the previous lower case letter (e.g. Bath is before bath but
after axe). Optionally, an upper case letter is treated as equivalent to a
lower-case letter.



Digits or numbers


Foreign characters

The relationship of one string to another may be

Equal   All characters or numbers are the same or equivalent.

Lesser  The first part of the first string, which is different from the
        corresponding character in the second string, is before it in the
        defined order.
Greater The first part of the first string, which is different from the
        corresponding character in the second string, is after it in the
        defined order.

Types of Comparison
Comparisons may be:

Type 0  Made directly on a character by character basis

Type 1  Made ignoring the case of the letters

Type 2  Made using the value of any embedded numbers

Type 3  Both ignoring the case of letters and using the value of embedded

Translation table
An optional 256 byte translation table may be used together with the four
comparison types described. This could be based on a different charcter
set or, for example, to equate accented characters to their un-accented
counterparts. See a crude example in AccentTab_bas