Hi,
I've wondered why my
text comparison wont work - it was because of
spaces on both or on one end of my strings which I would like to compare. i.e. " eugen beck" or " eugen beck ".
AHK's function "autotrim on" was not what I'm looking for and it wont work for my problem.
That's the reason why I wrote this little script:
Code:
/*
from a given string, all spaces on left and right side are trimmed,
both side trimmed string is given back
J.M., 21.02.2009 / 18:54
*/
fullstringtrim(text)
{
Length := StrLen(text)
; find all spaces on text's left side
LZ_left:=0
loop %length%
{
textchar:= Asc(SubStr(text,A_index,1))
if textchar = 32 ; is it a space ?
LZ_left+=1
else
break ; first good char found, exit
}
; find all spaces on text's right side
LZ_right:=0
loop %length%
{
textchar:= Asc(SubStr(text,length+1-A_index,1))
if textchar = 32 ; is it a space ?
LZ_right+=1
else
break ; first good char found, exit
}
treturn:=SubStr(text,LZ_left+1,length-LZ_left-LZ_right)
return treturn
}
Possibly somebody else can use it.
Greetings
J.M.