× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 2011/7/14 10:04 AM, Robert Munday wrote:

I need to test an array to determine if there are any non-blank elements.
In fixed format I recall that I could test the whole array. That seems
not to work in /Free format.


Here's another way to do this. It's a bit more code than some of the other solutions, but the advantage is that it works for any type of array, since the comparison is done on the array elements themselves rather than on the bytes of the whole array.

D arr s 5a dim(4)
D chk s n dim(%elem(arr))
D p s 10i 0
/free
// set up the array data
arr = *blanks;
arr(3) = 'a';

// chk(i) gets '1' if arr(i) is blanks, '0' otherwise
chk = (arr = *blanks);

// look for a '0' in the chk array
p = %lookup('0' : chk);
if p <> 0;
dsply ('element ' + %char(p) + ' is not blank');
endif;

*inlr = '1';

The chk array could be arbitrarily large.

D chk s n dim(1000)
...
p = %lookup('0' : chk : 1 : %elem(arr));

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.