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,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'
How do you do that??? It's early and I've not had enought coffee!!!
Thanks
Steve
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
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.
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......
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
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.