开发者

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

开发者_如何学C

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?


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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜