[comp.sys.apple] Case-insensitive string comparisons

fredc@pro-citadel.cts.COM (Fred Condo) (05/16/88)

David:

The key to case-insensitive comparisons is to convert both your
keyboard-entered string and the strings you are comparing to to the same
uniform case. Thus, let us say your database contains "David Oberhart" and you
type "DAVID OBERHART" at the keyboard. Your goal is to convert both to the
form "DAVID OBERHART" or "david oberhart".

The following code will convert the string A$ to ALL CAPS:

1000 B$=""
1010 FOR C=1 TO LEN(A$)
1020  C$=MID$(A$,C,1)
1030  IF C$>="a" AND C$<="z" THEN B$=B$+CHR$(ASC(C$)-32) : GOTO 1050
1040  B$=B$+C$
1050 NEXT C
1055 A$=B$
1060 RETURN


I hope this helps you out.

=============
|Fred Condo |
=======================================================
| UUCP: crash!pnet01!pro-sol!pro-la!pro-citadel!fredc |  Secular humanism:
| ARPA: crash!pnet01!pro-sol!pro-la!pro-citadel!      |  it stands to reason.
|       fredc@nosc.mil                                |  --------------------
| INET: fredc@pro-citadel.cts.com                     |
| ProLine: fredc@pro-citadel                          |
=======================================================