slestak
slestak

Reputation: 153

How do you do a LOCATE in Unidata with BASICTYPE 'U' for @AM's?

I typically use BASICTYPE 'P' at our shop but had an occasion to use 'U' for a project and noticed that I could not do a locate on a dynamic array that is delimited by Attribute Marks.

Referencing the docs, it plainly states that in type U, not specifying an attribute expression is a syntax error. This seems like a huge oversight to me.

How would this be done without resorting to a for-loop to search for these items?

Upvotes: 0

Views: 1056

Answers (3)

Shawn McKnight
Shawn McKnight

Reputation: 98

If your array is delimited by attribute marks, you simply need to do your locate in the following syntax:

LOCATE expression IN array_name SETTING position_var THEN | ELSE ...

It's a bit trickier to locate within a value mark delimited array, which would be:

LOCATE expression IN array_name<1> SETTING position_var THEN | ELSE ...

Upvotes: 2

Dan McGrath
Dan McGrath

Reputation: 42038

When in BASICTYPE 'U', you could use the FIND statement instead.

From the manual:

Syntax
FIND expr IN dyn.array[,occur] SETTING f [,v[,s]] {THEN statements | ELSE statements}

Description
The UniBasic FIND command determines the position of the given expression in a dynamic array. FIND returns the attribute, value, and subvalue position of the found string. The expression must match the entire array element to make a matc

Upvotes: 0

Will Johnson
Will Johnson

Reputation: 17

There are two forms of the LOCATE statement

One takes the form of Locate xxx in yyy setting zzz then aaa else bbb and the other Locate(xxx;yyy;zzz) then aaa else bbb

Upvotes: 0

Related Questions