Peter,
Correct me if I'm wrong (I've not really used scope messages, although I've
seen some code where they're used), but a scope message scenario has program
A, which sends a scope message when it initializes. This scope message
specifies program B as the program to call when A ends. Then, when program A
does end (for whatever reason - normal, abnormal, ENDSBS, ENDJOB, ENDSYS,
whatever), program B is called by the system.
Well if the OP has a NEP which has opened a bunch of files etc. which should
be closed when the program ends (and maybe other stuff that should be
cleaned up), how does it sending a scope message help?
Assuming Program A is the NEP. It starts up, opens its files, does its mess
(which will require cleanup) and sends a scope message to tell the system to
invoke program B. At some point in the future, program A is ended, and the
system calls program B. Well program B is a separate program - how can it do
program A's cleanup? Surely, at the point that the system has called program
B, program A (the NEP) has *already* ended, leaving a mess behind. Maybe
program B could clean up some of that mess, but it doesn't in any way help
program A end 'gracefully', does it?
Or have I missed the point?
In the OP's case, he wanted program A (the NEP) to know when *it* was being
ended (because of e.g. an ENDSBS), so it could do its own cleanup. He was
concerned that if it was in the middle of a sleep cyccle, it wouldn't know
that its job was being ended. For this, there is no solution, except to use
a 'signal' (in the broader sense of the word) - either a special data queue
entry on a data queue that the NEP is monitoring being received to say "Hey!
End gracefully" or maybe a sigalarm being sent to the program which would
wake itself up from up from its sleep. I guess potentially using the SHUTDN
opcode would work, but only if the program was checking it often enough to
'catch' it before the system actually *did* shut the program down 9I think
there's only a short period of time between the system triggering the SHUTDN
flag and it actually ending the program).
Personally, I'd use the data queue method, because it allows you very simply
to have a command to send the 'end' data queue entry. It's very flexible and
neat. In fact, I've attached some code I wrote a while back for a 'generic'
data queue server. If anyone thinks it might make sense, let me know (it
doesn't help with triggering of the data queue, but it can be used as the
'server' portion). I was thinking about making t as a black-box tool, but I
really can't be bothered, so the code is for anyone to use. Just compile the
objects and try it out...
Rory
On Wed, May 20, 2009 at 8:31 PM, Peter Connell <
Peter.Connell@xxxxxxxxxxxxxxxxx> wrote:
Yes, devolved from "how to monitor EOJ for an RPG pgm" for which I still
recommend a scope msg.
I'm not going anywhere near the other discussion.
Peter
As an Amazon Associate we earn from qualifying purchases.