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



The point is to encapsulate the memory required by the parameters setup for the service program, or other related data.

Say we have Pgm1 and Pgm2.

-- pgm1 runs setup for service program
-- pgm1 calls PGM2
---- pgm2 runs setup for the service program
---- pgm2 runs procedure
--PGM2 returns to pgm1,
-- Then PGM1 runs the procedure.

With the pointer, each program gets its own set of memory to be used by the service program.
Then pgm1 and pgm2 do not interfere with each other.

With global memory, PGM2 would basically reset all the setup PGM1 made to call the procedure.

Since the programmer doesn't do anything with the pointer but define it, there isn't much to confuse anyone.

A nice example of this is in HTTPAPI service program.
The http_persist_open() procedure returns a pointer, and all the http_persist_get/post/req all get passed the pointer to the persistent HTTP comm session.


Chris Hiebert
Senior Programmer/Analyst
Disclaimer: Any views or opinions presented are solely those of the author and do not necessarily represent those of the company.


-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Jon Paris
Sent: Wednesday, May 17, 2017 8:26 AM
To: Midrange-L Midrange-l <midrange-l@xxxxxxxxxxxx>
Subject: Re: Service programs

Can you explain to me the point of using a pointer here Chris?

Surely passing the instance of the "object" in question has exactly the same effect - it is after all a pointer that is being passed anyway. What does exposing the pointer do for you except confuse pointer-phobic RPGers down the road?


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On May 17, 2017, at 10:21 AM, Hiebert, Chris <chris.hiebert@xxxxxxxxxxxxxx> wrote:

This method could be easily augmented to remove the use of global data by way of an additional Pointer parameter.

Ptr_cust = inventory_init();
inventory_setValue(Ptr_cust :'qtyLessThan':'10')
inventory_setValue(Ptr_cust :'itemType':'parishable');
inventory_listItems(Ptr_cust );

The caller defines the pointer and passes it to the Service Program Procedure.
Then all interaction with that instance passes along the pointer.
Allowing the pointer to act as a container of the "object" data.


I do find the idea of the setValue functions helpful for a service program like MailTool which would have many different options.

Although, I would probably end up creating a Helper procedure to wrap the calls to all the setValue procedures. This way I get one call that everyone can use and it contains all the parameters I would need with Options Omit/Nopass.

RDI has come a long way in matters of showing us the parameters required for a subprocedure. And even if that isn't working, we are usually only a few clicks away from looking at the prototype copybook.
So knowing the sequence of the parameters today shouldn't be an issue, depending on the tools you are using.

Also, you would have trouble setting this type of service program up as a SQL function without a procedure that includes all the parameters.

Chris Hiebert
Senior Programmer/Analyst
Disclaimer: Any views or opinions presented are solely those of the author and do not necessarily represent those of the company.


-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of
Bradley Stone
Sent: Tuesday, May 16, 2017 6:47 AM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Subject: Re: Service programs

One thing I like to do is use more generic procedures to set "parameter" values... ie:

function_setValue(parameter:value);

ie.
cstmst_setValue('custno':'993043');
cstmst_listOverdueInvoices();

or

inventory_setValue('qtyLessThan':'10')
inventory_setValue('itemType':'parishable');
inventory_listItems();

This way if you need to add parameters you simply update the
<function>_setValue() procedure and add new possible variables to set.
No change in signatures this way.

You could set up constants for the parameter names in the /copy files for the prototypes to make things easier as well.

Here's some documentation on just one application that I did it with:
http://docs.bvstools.com/home/mailtool/docs/chapter-3/-mailtool_setval
ue

Because I've had this in production at many shops I've found it works great and wish I would have done this before with my other applications.
Bradley V. Stone
www.bvstools.com
Native IBM i e-Mail solutions for Microsoft Office 365, Gmail, or any Cloud Provider!


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at
http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: http://amzn.to/2dEadiD

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.