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



Don Wereschuk wrote:
Hi All: Thanks to all the replies. I ended up using Adam's suggestion by using %subst().

Scott, your code was very similar but what I was trying to do was pass the name of the field and not the actual data in the field ( not filerec.PLCD but 'filerec.PLCD' and could only do this using pointers )

I think Scott's code should work too Don. When you pass parameters in RPG, you're really using a pointer implicitly. Again, Scott suggested this code:
> P FillArrayAll B
> D FillArrayAll PI
> D FieldToCheck 50a options(*varsize)
> D len 10i 0 value
> D CheckValue 50A const
> D ArrayValue 50A
>
> You'd call it with something like:
>
> FillArrayAll(filerec.PLCD: %len(filerec.PLCD): 'whatever': whatever);

If you write your procedure like this, FieldToCheck and fileRec.PLCD will actually refer to the same memory. The 'options(*varsize)' tells the compiler "don't force me to pass a 50A, I know what I'm doing". That's why you need the length as well - if you pass a 10A and don't take the length into account, you will mess up the next 40 bytes of memory as well. Just like when you use a pointer, you have to be very careful that you only touch the memory that the caller told you to.

Anyway, I think Scott's version is cleaner and more straightforward. I'd consider using that version if I were you.

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.