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




Just curious the reason of based keyword design in RPG.  If they are
tightly integrated, why not just allow doing the following:
%addr(myField) = myPointer;

Hmmm... I don't know why they did things the way they did them. Maybe Barbara or Jon would know?

One problem with your suggestion is that you'd still need a way to mark a field (on the D-spec) as one that the program will control the storage for. Typically, a standalone variable defined on the D-spec will automatically have memory allocated for it when the procedure/program starts up. And that memory will be automatically released when the program stops. One of the things the BASED keyword does is tell the runtime NOT to ask for memory for the field when the program/procedure starts.

So, you could potentially have a USRSTG keyword (or whatever name makes sense) on he D-spec, and then have the compiler use %addr() on the left-hand side of an EVAL to control the area of memory the field points to. That'd certainly work.

Though, I think the way they did it (with BASED and a pointer) is probably easier for people to understand. If they used %ADDR() on the left-hand side of the expression, you'd be getting lots of messages on this forum from people who used %ADDR() but didn't use USRSTG, and don't understand why their program doesn't compile. Or people who specified %ADDR() (on the left side) for a subfield of a data structure. Or on a parameter. IMHO, the based() syntax makes things a little easier to understand, and a little easier to avoid mistakes.

But, thinking of it in terms of %addr(Field) = pointer is a good sign -- it shows that you understand what BASED does :)

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.