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:


instead of the correct statement:


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).