Page 1 of 1

search function

Posted: Thu May 11, 2006 5:32 pm
by sainath
Hi
I am wondering is there any scan or search function which searches for perticular key word .
Like i want to populate all data which matches with 'ADDED XXX' in a column.
THKS

Posted: Thu May 11, 2006 5:53 pm
by DSguru2B
The lookup methodolgy is the best to suit your needs. If you need something specific then be more elaborate on your question.

Posted: Thu May 11, 2006 6:02 pm
by chucksmith
Take a look at the Index() function. It will return a non-zero value if the substring you are searching for is found in the string.

Posted: Thu May 11, 2006 6:57 pm
by chulett
That non-zero value that Index() returns is actually the starting position of the sub-string if it is found. The nice thing about that is, if you don't care where the sub-string is found but only if it is found, you can use that as a boolean. For example:

Code: Select all

If Index(Link.Column,'ADDDED',1) Then <do something> Else < do something else>
If 'ADDED' is not found in the column it will return a zero which is interpreted as False. And since any non-zero value evaulates to 'true', the starting position of the sub-string can be leveraged as indicated.

Hope that helps,

Posted: Fri May 12, 2006 6:32 am
by gateleys
Try:

Code: Select all

If(InLink.Column MATCHES "0x'ADDED'0x") Then someValue Else otherValue
gateleys

Posted: Fri May 12, 2006 7:54 am
by ArndW
Gateleys,

for your information, although the MATCHES function will work; it uses 32 times more CPU than the INDEX function and that will add up to a lot slower execution or heavier CPU load in a real job.

Posted: Fri May 12, 2006 8:23 am
by gateleys
Agreed. :) Arnd, can you please give a brief comparison between the various comparison/search functions (in terms of efficiency)? And also, scenarios when each would be effective? Would be really neat.

gateleys

Posted: Fri May 12, 2006 8:28 am
by ArndW
The INDEX function is used frequently and has been very well tuned. It is also (algorithmically) quite a simple linear search for a substring so is easy to implement. The MATCHES function is much a more complex pattern matching function which has to parse the picture string into it's components and then search the string for all components to match. You should use MATCHES or MATCHFIELD or the other pattern matches when a simple INDEX doesn't suffice.

Your matches idea was good, I just wanted to make sure that it was understood that there is a price to pay for that flexibility.