Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

LB_FINDSTRINGEXACT not working?

davidgraham
Beginner
544 Views
Is LB_FINDSTRINGEXACT not working with case?
I have a list containing 'cat' and I do

ctext='Cat'//c
iret=SendMessage(hs,LB_FINDSTRINGEXACT,-1,loc(ctext))

iret is not LB_ERR but the location of 'cat'.

The documention says for LB_FINDSTRING - The search is case independent, so this string can contain any combination of uppercase and lowercase letters.
for LB_FINDSTRINGEXACT - The search is not case sensitive, so this string can contain any combination of uppercase and lowercase letters.
To me this does not make sence, or am I calling doing it wrong.

David
0 Kudos
3 Replies
anthonyrichards
New Contributor III
544 Views

LB_FINDSTRING finds the first string that BEGINS with the specified string, but ignoring case.
LB_FINDSTRINGEXACT finds the first string that EXACTLY matches the specified string , ignoring case .
I presume this to mean if you search for null-terminated string 'Character' and have null-terminated 'CHARACTERSTRING' and 'CHARACTER' strings in your list in that order, LBFINDSTRINGwillreturn the index for 'CHARACTERSTRING' whereas LBFINDSTRINGEXACTwillreturn the index for the 'CHARACTER' item.

0 Kudos
davidgraham
Beginner
544 Views
Thanks,
If I search for null-terminated string 'Character' and have null-terminated 'CHARACTERSTRING' and 'CHARACTER' strings in my list -
I expected it to return LB_ERR as it couldn't find it as it wasn't an exact match.

I now see this isn't how it works.

Is there no way I can search for an exact match on an item in a list without stepping trough the items one by one?

David

0 Kudos
anthonyrichards
New Contributor III
544 Views

It looks like you will have to do your own case-sensitive search after an exactmatch is found to your searchstring and ifthat fails to throw up a match, you do another LB_FINDSTRINGEXACT search from the next item in the list, and so on. This requires you to get the text string using LB_GETTEXT (put it into foundstring) and then do your own test for equality using

IF(foundstring(1:index(foundstring,char(0)).eq.searchstring(1:index(searchstring,char(0)))

and so on.

0 Kudos
Reply