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



David FOXWELL wrote:
...
I just wrote my first program ever that passed a pointer from one
program to another. I used it to access a data structure in the
calling program that was alimented by the program being called. I
won't explain why I did not just pass the data structure as a
parameter. ...

Hi David, you said that you won't explain why you didn't just pass the data structure as a parameter. But ... I have to ask anyway :) I think it's an important question.

When you define your procedure to have a pointer parameter, you are making it difficult to call the procedure correctly.

It's very easy to call your program correctly:
PGM2 (%addr(MyDs));

But with that prototype, it's also very easy to call it incorrectly:
PGM2 (%addr(*INLR));
PGM2 (%addr(MyDs(i).mySubfield));

If you want your program to be passed a data structure, then the best idea is to code the prototype to say this, by defining the parameter with LIKEDS. When the prototype says that your program wants to be passed a pointer, you make it impossible for the compiler to ensure you pass a correct parameter, and you make it difficult for other programmers to know what to pass as a parameter.

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.