March 28, 2024, 07:23:49 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Insensitive strings

Started by aurelCB, September 22, 2009, 12:33:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aurelCB

Hi people... :)
How make string with case insensitive?
Put another way - how to compare the two strings that have the same meaning.
For example if we have string "byte" and string "BYTE" , so how make program which can
recognize string writen as "bYte" or "Byte" or "byTE" ?
Is there any example how do that?

thanks advance...
Aurel

aurelCB

Oh my  ::) I must reply to myself.
I completly forget one simpliest solution( like usual...)
small example:
'MAIN SKELETON
DEF w1:window
def text,Str,keyword:string

Window w1,0,0,400,300,@minbox,0,"Strings",main
Setwindowcolor w1,rgb(200,200,200)
'-------------------------------------------------------
Str="nEw"
'so i just trnsform new string to lower case ...
keyword=Lcase$(Str)

IF keyword="new"
move w1,10,10:Print w1,keyword
ELSE
move w1,10,50:Print w1,"Not match..."
ENDIF


'----------------------------------
run=1
waituntil run=0
closewindow w1
end
'----------------------------------
Sub main
select @class
case @idclosewindow
run=0
case @idcreate
centerwindow w1
endselect
Return


Ionic Wind Support Team

That will work, but you can also use the lstrcmpi API function.

http://msdn.microsoft.com/en-us/library/ms647489(VS.85).aspx

The declare for Creative would be:

declare "kernel32",lstrcmpi(st1:string,str2:string),int

small example:


openconsole
declare "kernel32",lstrcmpi(st1:string,str2:string),int

if lstrcmpi("new","NeW") = 0
print "Matches"
endif


This would be the fastest solution.

Paul.
Ionic Wind Support Team

aurelCB