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



Hi Barbara

Had not seen this syntax before

chk = (arr = *blanks);

I looked up "=" under "compare operations" in the ILE RPG v5 Language
reference.
It had this statement.

"An array name cannot be specified in a compare operation, but an array
element may be specified."

wrote this pgm like yours and it worked fine.

D ARR S 5A DIM(4)
D CHK S N DIM(%ELEM(ARR))
/FREE
*INLR = '1';
CHK = (ARR = *BLANKS);
/END-FREE

What does that statement from the manual mean? Is "=" not a compare
operation?

Jim



------------------------------

message: 4
date: Thu, 14 Jul 2011 18:17:27 -0400
from: Barbara Morris <bmorris@xxxxxxxxxx>
subject: Re: Testing An Array


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