0

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?

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
slestak
  • 153
  • 1
  • 8
  • I think the question is a little misleading. The title gives the impression that you're seeking to locate attribute marks. The detail of the question is pretty clear that you're seeking to locate within an attribute marked dynamic array. – Shawn McKnight Aug 07 '13 at 02:02

3 Answers3

2

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

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

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
0

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

  • 1
    This doesnt appear to answer my question. Does the funtion version of LOCATE() not have this BASICTYPE difference? – slestak Feb 12 '11 at 10:22