Comparing Strings

Since each character has a value (its ASCII number), characters can be compared in the same way as numbers. This means that the expression ('A' < 'C' ) evaluates to True because 65 is less than 67. Note that the expression ('X' < 'x') evaluates to True because 88 is less than 120. Also, because characters are compared one by one, ('ab' < 'ac') evaluates to True. Strings are sorted in dictionary order, so that 'a' is less than 'ab' and '8' is less than '8.0'..

In order to compare strings you can either use code such as if Name1 < Name2 then ... or a routine. There are many routines because of the different types of string and because some of the comparisons are case sensitive. As a general rule, when text is in the identifier (such as textCompare) the routine is not case sensitive and when str is in the identifier (such as strCompare) the routine is case sensitive.

Programming - a skill for life!

Introduction to string routines such as the concat function