|
Scott, Hmmm... this gets rid of my problem about my data being public, but... in this case don't I just have one copy of the data structure out there? As I understand your C method, to use this I would have to do something like: *** In the copy source the data structure RNF_Data is set up based on RNF_Data@ *** //COPY QMODSRC,SYSTEMPR D RNF_Data# S 107A C Eval RNF_Data# = RNF_Open('QPGMR': 'ICS400') C Eval RNF_Data@ = %addr(RNF_Data#) C DoW NOT RNF_Data = *Blanks C If NetFile = 'MYFILE' ... C Eval RNF_Data# = RNF_Read C Eval RNF_Data@ = %addr(RNF_Data#) C EndDo The whole point being, I am going to have to reset the pointer to my local data buffer every time I call a function that could set it to it's own local data buffer (like RNF_Open and RNF_Read would do). I like it, I just don't like the side effect of functions changing my pointer, which is at this point a global variable. Regards, Jim Langston Scott Klement wrote: > C) Use pointer-based structures in a /COPY file, and then define a local > variable for each copy of the structure you want, and point > the DS at the local var. > > Like so: > > (in /COPY member:) > D mystruct ds BASED(p_mystruct) > ... subfields here.... > D p_mystruct S * > > (in proc where you use it:) > D/COPY SOURCE,MEMBER > D MyNewStruct S 16A (or however big the DS is) > D MyNewStruct2 S 16A (or however big the DS is) > c eval p_mystruct = %addr(mynewstruct) > c ... work with vars in mynewstruct ... > c eval p_mystruct = %addr(mynewstruct2) > c ... work with vars in mynewstruct2 ... > > Personally, I find myself using "C". I like putting my structures in the > same /COPY member as the prototypes that they correspond with. Most > people, however, aren't as comfortable with pointers as I am. +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
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.