|
I have a data struct. It contains a pointer.
d DemoDs ds qualified
d pData *
I can copy the data struct and the pointer stays pointed.
d ds1 ds likeds(DemoDs)
d ds2 ds likeds(DemoDs)
d street s 10a
street = 'maple ave' ;
ds2.pData = %addr(street) ;
ds1 = ds2 ;
DsplyDs( ds1 ) ; // works!
I can return the ds from a proc and the pointer is still pointing.
ds1 = AssignDs( Street ) ;
DsplyDs( ds1 ) ; // also works.
But when I return the data struct from a proc and on the same stmt pass the
data struct as an arg to another proc:
DsplyDs( AssignDs( address )) ; // fails
the pointer arrives in the called proc as not set.
Am I doing something wrong here? Is this a feature or a bug?
I am at v5r1, have downloaded a lot of RPG PTFs from the IBM support site.
But I dont have software support, so cant call IBM on this.
thanks,
Steve
here is the complete code:
h option(*SrcStmt)
d bug1 pr extpgm('BUG1')
d DemoDs ds qualified
d pData *
d AssignDs pr likeds(DemoDs)
d InVar 10a
d DsplyDs pr
d InDs value likeds(DemoDs)
d Street s 10a
d ds1 ds likeds(DemoDs)
d ds2 ds likeds(DemoDs)
/free
street = 'maple ave' ;
// assign, then display.
ds1 = AssignDs( street ) ;
DsplyDs( ds1 ) ;
// assign, then display. only do the assign as an expression
// that assigns the value to arg1 of the dsply proc call.
DsplyDs( AssignDs( street )) ;
return ;
/end-free
** ------------------------ AssignDs ------------------------
p AssignDs b
d AssignDs pi likeds(DemoDs)
d InVar 10a
d ds1 ds likeds(DemoDs)
/free
ds1.pData = %addr(InVar) ;
return ds1 ;
/end-free
p e
** ---------------------- DsplyDs ------------------------------
pDsplyDs b
dDsplyDs pi
d InDs value likeds(DemoDs)
dDsData s 10a based(InDs.pData)
/free
dsply DsData ;
/end-free
p e
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.