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



So you agree that the way to solve this issue is with some sort of "instance" variable.

So is your only concern related to the data type?

I tent to use a pointer so that the service program can control the allocation and layout of the data.

It could have just as easily been a Char(32768) or a Data Structure field.
However that implementation would limit the Service program to that specific definition.
With the Data Structure, the caller becomes somewhat "aware" of what the Service Program is saving.

The pointer allows the complete encapsulation of the data, but still allowing each call to have its own instance.

But in those examples I am always passing something into the procedure.

There are other ways of accomplishing this type of instance.
For example the procedure could auto generate some sort of UUID field and either return it or link it to the caller in an internal array.
Generating the id on the first call and then using the id to access some other sort of memory, like a user space or user index in QTEMP or a database file.

I've considered the issues with the different implementations over the years, and generally find that passing the pointer to contain the instance data is quicker to implement.

I guess what I'm missing is the service program to automate the tracking of the instance data.

We do have a service program that tracks its instance information using the Call Stack of the caller as the Id. For me the downside is the time it takes to get the call stack information.

In the case of the pointer (or another type of instance variable), the variable gets passed and is immediately available to the service program procedure.

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 9:12 AM
To: Midrange-L Midrange-l <midrange-l@xxxxxxxxxxxx>
Subject: Re: Service programs

HTTPAPI is a case where some for of "handle" is needed to identify the session. Same scenario with using the C I/O APIs where either a pointer or an integer is used as the handle.

I understand what you are saying - but it just seems to me that the pointer usage itself could have been restricted to usage as a basing pointer if dynamic memory was even essential. In the case you quote, both PGM1 and PGM2 could surely each have defined their own "instance" variable and passed that to the service program routines. Those variables would be global (or legal depending on program structure) but still unique to the program.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

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.