Compare n characters from strings

#1
Hi there...

Is there such a way to do this on Amibroker like this function on Matlab?
http://www.mathworks.com/help/matlab/ref/strncmpi.html

Compare n characters from two strings independently of it's length... example:

string1 = "Hello World Good Morning"
string2 = "Hello World Goo"

result = TRUE if 15 left characters match.

I had been searching for a general way to do this on AFL but it seems there is not such a function hard coded.

Is there a way to code it on AFL..?

Thanks
 

colion

Active Member
#2
Hi there...

Is there such a way to do this on Amibroker like this function on Matlab?
http://www.mathworks.com/help/matlab/ref/strncmpi.html

Compare n characters from two strings independently of it's length... example:

string1 = "Hello World Good Morning"
string2 = "Hello World Goo"

result = TRUE if 15 left characters match.

I had been searching for a general way to do this on AFL but it seems there is not such a function hard coded.

Is there a way to code it on AFL..?

Thanks
You can compare the two strings with StrLeft().

x = "abcdef";
y = "abc";
compare = iif( strleft( x, 3 ) == strleft( y, 3 ), 1, 0 );
 

mastermind007

Well-Known Member
#3
Hi there...

Is there such a way to do this on Amibroker like this function on Matlab?
http://www.mathworks.com/help/matlab/ref/strncmpi.html

Compare n characters from two strings independently of it's length... example:

string1 = "Hello World Good Morning"
string2 = "Hello World Goo"

result = TRUE if 15 left characters match.

I had been searching for a general way to do this on AFL but it seems there is not such a function hard coded.

Is there a way to code it on AFL..?

Thanks

Code:
if (StrFind(string1, string2) != StrFind(string2, string1)) 
{ 
_TRACE("Match found");
}