Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Passing data structures as parameters in RPGIV

754 views
Skip to first unread message

Steve

unread,
Apr 9, 2009, 3:37:30 AM4/9/09
to
Hi,

I'm trying to pass a datastructure as a parameter from a program to a
service program. I'm trying to do it by passing a pointer to the data
structure from the callling program to the receiving program;

Calling program;

MoveOp.batchCard = batbat ;
MoveOp.From_OpCode = *blanks ;
MoveOp.To_OpCode = '0040' ;
MoveOp.ResetQty = *on ;
fnCreateMOP( %Addr(MoveOp)) ;

Receiving program;

p fnCreateMOP b
export
d fnCreateMOP
pi
d p *
const
d pm ds likeds(MoveOpDS) based
(p)

Unfortunately when I run it through debug and check the values in 'PM'
all of the fields are filled with '*'.

What am I doing wrong? Is there an easier way of doing it than
passing the datastructure as a pointer?

Thanks

Steve

Dr.Ugo Gagliardelli

unread,
Apr 9, 2009, 4:03:54 AM4/9/09
to
il 09/04/2009 9.37, Scrive Steve 43191376:
You shold pass the pointer by-value, specifying value on the pointer
argument, otherwise your called proc will receive the address of that
pointer.

--
Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherA�ejoAlcoolInside
Spaccamaroni andate a cagare/Spammers not welcome/Spammers v�o � merda
Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'

Steve

unread,
Apr 9, 2009, 4:02:58 AM4/9/09
to
Hi,

How do you do that??? It's early and I've not had enought coffee!!!

Thanks

Steve

Dr.Ugo Gagliardelli

unread,
Apr 9, 2009, 5:39:29 AM4/9/09
to
il 09/04/2009 10.02, Scrive Steve 43191376:
A procedure like:

D proc pr
D argptr * value

will pass the pointer argument by-value, so the pointer itself, while:

D proc pr
D argptr *

will pass the pointer argument by-reference, so the address of the
pointer argument

jb

unread,
Apr 9, 2009, 5:51:09 AM4/9/09
to

Wouldnt
fnCreateMOP( MoveOp) ;
simply pass the address of the ds? Then in your called program
pi
d pm ds likeds(MoveOpDS)
would get that pointer & associate pm with it? Just like any other RPG
program.

Jonathan.

Steve

unread,
Apr 9, 2009, 6:56:43 AM4/9/09
to

I tried it like that at first but it won't compile because it's not
defined as a parameter. That's the reason why I went for the pointer
to the data structure option......


jb

unread,
Apr 9, 2009, 10:40:22 AM4/9/09
to
> to the data structure option......- Hide quoted text -
>
> - Show quoted text -

How about
pi
d parm likeds(MoveOpDS)
d pm ds likeds(MoveOpDS)

then move parm into pm? You might not be able to make parm likeds in
that case & it could be hard to 'automatically' make the field long
enough in case someone makes changes so maybe

pi
d parm 10 (or any length since its
just used as a pointer)
d pm ds likeds(MoveOpDS) based(p)
d p *
then eval p=%addr(parm)

Jonathan

Barbara Morris

unread,
Apr 22, 2009, 7:02:50 PM4/22/09
to
Steve wrote:
>
> I tried it like that at first but it won't compile because it's not
> defined as a parameter. That's the reason why I went for the pointer
> to the data structure option......
>

Did your prototype and PI both define that parameter with LIKEDS? Could
you show the error messages you got from the compiler?

What Jonathan suggested should work.


0 new messages