David J Murray Dev
~ Learn and Do - Excel and Share ~

Locate Locate Locate

Nov 29, 2005
You're Reading: Locate Locate Locate

A post in MVDBS & Techniques & UniBasic

I use the PICK format for the LOCATE statement in UniBasic.

But, this time, I could not understand why the statement would not find a value in a record.

Eventually, it dawned on me that I had used the dynamic notation for the multivalue element rather than the field and value expressions:

LOCATE(SEARCH.VALUE, RECORD<12>;; FOUND.POS) THEN...

instead of the correct statement:

LOCATE(SEARCH.VALUE, RECORD, 12; FOUND.POS) THEN...

Wakey wakey boy…

This got me thinking about what the LOCATE does as there are a number parameters to the statement and there are also similar functioning statements of FIND and FINDSTR.

Most of the time, I use the LOCATE with the SEQ parameter to create and maintain ordered lists (multivalue and multisubvalue). But it works equally well on non-ordered lists. What differentiates the LOCATE from the FIND statement is the LOCATE has the ability to restrict searching to a field, value and/or subvalue element of the record.

So, my first LOCATE code above will do a field search in the 12th field of the record looking for the SEARCH.VALUE as a field.

The 2nd LOCATE code above will do a value search in the 12th field of the record looking for the SEARCH.VALUE as a value.

The FIND statement does a search thoughout all fields, values and subvalues within the record setting found field, value and subvalue elements. It is not possible to localise the search to a field or value.

This does have it’s uses as I have used the FIND and FINDSTR statements for doing text find and replacement in free-form text records (think mail merge functionality).

About the Author

<a href="https://davidjmurray.dev/colomem/davidjmurray/" target="_self">djm</a>

djm

I have been in the computer/IT industry for over 35 years. After spending half a life-time in highly proprietary database environments, I have succumbed to the WordPress Eco-system and I'm well down the chasm. I am specializing in AWS hosting, Wordpress CMS, Elegant Themes, in particular Divi and Extra themes.

0 Comments

Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This