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



Hi Robert, I just had an idea. If you truly don't want getDaysOfWeek touching subfield1. However I will say that I don't really see any harm in subfield1 being set by that procedure. In fact, I would suggest, as in my last email, sending the starting day as a separate parm, then the procedure loads it into the DS along with all of the other subfields it's loading.

But, here's an idea on getting getDaysOfWeek to not touch subfield1 at all.

d testpgm7 pr

d t_DayDs ds template
d subfield1 10a varying
d subfield2 like(subfield1)
d subfield3 like(subfield1)
d subfield4 like(subfield1)
d subfield5 like(subfield1)
d subfield6 like(subfield1)
d subfield7 like(subfield1)

// define this within the service program's copybook
d t_NewDayDs ds template
d subfield2 10a varying
d subfield3 like(subfield2)
d subfield4 like(subfield2)
d subfield5 like(subfield2)
d subfield6 like(subfield2)
d subfield7 like(subfield2)


d testpgm7 pi

d DayDs ds likeds(t_DayDs)
d newDayDs ds likeds(t_newDayDs)

/free
*inlr = *on ;

DayDs.subfield1 = 'Sunday';
GetDaysOfWeek(Days.subfield1: newDayDs);

// I think eval-corr is available at v6.1. will load all the subfields except subfield1.
eval-corr DayDs = newDayDS;

Return;
/end-free


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Robert Rogerson
Sent: Friday, June 15, 2012 2:31 PM
To: RPG programming on the IBM i / System i
Subject: Explanation of a datastructure as a parameter...

Hi All,

I'm just hoping that someone can spare a moment and help me understand
this better.

I'm unclear how or if I can stipulate a parameter as const when passing a
datastructure defined like a template. For example, see the following
code.

h option(*nodebugio:*srcstmt)
d testpgm7 pr

d t_DayDs ds template
d subfield1 10a varying
d Overlay(t_DayDs)
d subfield2 like(subfield1)
d Overlay(t_DayDs: *next)
d subfield3 like(subfield1)
d Overlay(t_DayDs: *next)
d subfield4 like(subfield1)
d Overlay(t_DayDs: *next)
d subfield5 like(subfield1)
d Overlay(t_DayDs: *next)
d subfield6 like(subfield1)
d Overlay(t_DayDs: *next)
d subfield7 like(subfield1)
d Overlay(t_DayDs: *next)

d testpgm7 pi

d DayDs ds likeds(t_DayDs)

/free
*inlr = *on ;

DayDs.subfield1 = 'Sunday';
GetDaysOfWeek(DayDs);

Return;
/end-free

p GetDaysOfWeek b
d GetDaysOfWeek pi
d i_DayDs likeds(t_DayDs)
/free
*inlr = *on ;

If i_DayDs.subfield1 = 'Sunday';
i_DayDs.subfield2 = 'Monday';
Endif;

Return;
/end-free
p GetDaysOfWeek e

The datastructure DayDs is defined like the template t_DayDs. I don't
want the procedure GetDaysOfWeek to be able to change subfield1. If I had
passed all 7 parameters I would have specified the keyword const for the
first parameter.

How or can I do with a keyword when I pass a datastructure.

Thanks to all in advance.

Robert Rogerson
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.