Hi there people.

I've written a file search routine in ASM and it works fine. Basically u pass in a filename to scan and the text to find and off it goes. The only issue I have is that it is case sensitive. So if I search a file for the letter 'A' and the file has a letter 'a' - it'll return a False result.

How can I make this routine case insensitive so tha in the search for letter 'A' above, it'll return True even if 'a' is in the file?

Here's a code snippet. It was written in PowerBASIC DLL version 7. (I tried MASM 7, trust me, but got into some difficulties with passing stuff from VB)
Basically we do a compare on the ASCII char values of each character in the file, to each character in the search text.



bytChar = Asc(sText, lCharIdx)

!Mov BL, BYTE PTR [EDI]
!Cmp BL, bytChar



Thanks.
Jas.
Posted on 2002-12-18 09:25:06 by MrClyfar
well either convert all letters to uppercase or lowercase and then compare

A is 41h a is 61h , 20h difference (32) so if you chose uppercase and you see a number between 61h and 7ah then you subtract 20h to get the uppercase equivalent.

This is of course provided you only compare ASCII strings.

edit: what I almost forgot, on any computer with at least IE4 you can use StrCmpI for the comparison

98+ and 2K+ have it natively, everything before needs IE4
Posted on 2002-12-18 09:41:03 by Hiroshimator
Damn Hiro beat me to it , oh well I'll carry on anyway:)

41 = A = 1000001; 61 = a = 1100001

therefore ORing any uppercase value with 20h will set bit number five and convert it to lowercase.

.if (al>40h && al <5bh)
or al,20h
.endif

btw, XORing any (ascii) value with 20h toggles between upper and lower case.

best regards,

czDrillard
Posted on 2002-12-18 09:50:15 by czDrillard