September 20, 2020, 03:48:27 am

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


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
forum for hobby programming:<br />https://aurelsoft.ucoz.com

aurelCB

Oh my  ::) I must reply to myself.
I completly forget one simpliest solution( like usual...)
small example:
Code Select
'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

forum for hobby programming:<br />https://aurelsoft.ucoz.com

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:

Code Select

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

forum for hobby programming:<br />https://aurelsoft.ucoz.com