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




Steve,

You don't have to pass a pointer to the data structure. When you pass a field, and don't include VALUE or CONST on the prototype, a pointer will be passed under the covers. However, the fact that you don't manually code the pointer logic allows the compiler to do better validity checking and makes it easier for the caller, since he doesn't have to do any pointer logic.

Also, if you _do_ use CONST, but the caller's definition for the parameter is identical to the subprocedure's, then it'll still be passed by pointer under the covers. Coding VALUE will guarantee that it's not passed by pointer -- so you don't want to do that :)

For example:

     d FeatTypeDS      ds                  Qualified
     d   dsFeat                       3    dim(1000)
     d   dsType                       2    dim(1000)
       .
       .

       if ErrorsInDS(FeatTypeDS);
     .. do whatever ..
       endif;
        .
        .

     P ErrorsInDS      B
     D ErrorsInDS      PI             1N
     D    Feat                             likeds(FeatTypeDS)
      /free
          for x = 1 to %elem(Feat.dsFeat);
              if Feat.dsType(x) = 'AB';
                  .... do something ...
              endif;
          endfor;
      /end-free
     P                 E

This is just so much more elegant than passing a pointer directly.. The only time I'd pass a pointer directly is when you're deliberately using a pointer rather than something like a data structure, or when you want the routine to be available to any data type.

---
Scott Klement  http://www.scottklement.com


On Tue, 23 May 2006, Ellsberry, Steve wrote:

I have a program that contains a data structure and a pointer defined
as:

d FeatTypeDS                ds             Qualified
d   dsFeat                                3     dim(1000)
d   dsType                               2     dim(1000)

d    PointerToDS             s          *

I set the pointer by using:
PointerToDS = %ADDR( FeatTypeDS )

I have a procedure called ErrorsInDS in a service program that accepts a
pointer as a parameter and returns a Boolean. I get to the procedure by
using...

If ErrorsInDS( PointerToDS );

In the service program I have the procedure interface defined as
p  ErrorsInDS                 pi                   n
      PointerPassedIn                            *

I also have a data structure in the procedure defined as
d FeatTypeDS                ds             Qualified
Based(PointerPassedIn)
d   dsFeat                                3     dim(1000)
d   dsType                               2     dim(1000)
I'm trying to manipulate the data within the DS from my service program
without duplicating the contents of the data structure and without
actually passing the data. I figured the DS in the service program would
be exactly as the DS in the calling program but it's not. The memory
address leaving the program, PointerToDS, and entering the service
program, PointerPassedIn, is exactly the same but the contents of the DS
in the service program is not the same as the DS in the program. The
program has valid data. The DS is the service program contains all
asterisks.

Any ideas what I'm doing wrong?


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.