× 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 chaps,
 
We have a RPG program which uses a display file. Originally, the screen was
set up with the INVITE keyword and a WAITRCD of 1 second. Each second it
would drop off a READ and check the status of the user's phone. The screen
would then update with the connection details.
 
Although this architecture was sufficient we moved to a modular approach -
breaking the phone checking logic out of the program screen loop processing
and firstly putting it into a separate sub-proc, but ultimately putting it
into a separate service program. After looking at, and discarding SPECIAL
files (although I think they are really cool and much under-used) we finally
settled on an architecture as follows:
 
Dow not *INKC, *INKL, etc...
 
    Prepare screen fields
    WRITE screen format
    addListener(sds_program :%paddr(sub-procPGM) *NOTE1
    READ(e) screen format
    removeListener() *NOTE2

    if %error()
        CLOSE display file
        OPEN display file
    endif
 
    other stuff, validation, processing, etc...
 
enddo
 
*NOTE1:
This calls a service program sub-proc to enable signals and pass the
paddress of a sub-proc within the service program (to be called in the event
of a SIGALARM signal). This set-up code would only run only once. On every
call it calls alarm(1).
 
*NOTE2:
This calls a service program sub-proc to clear the listening sub-proc fields
and then calls alarm(0) to disable the alarm.
 
Now, every second the service program sub-proc is called. This calls
sub-procPGM within the program and if this returns true an *ESCAPE message
is sent by the service program to the program (sds_program). This error is
trapped by the (e) extender on the READ and all is good - we are now off the
READ and back running through the code. The code uses less CPU than the
original INVITE method and the program sits on the READ(e) until the user
presses a valid key or an event occurs which causes the program sub-proc to
return true (call begins/ends/is transferred/etc). 
 
Now, I just read Scott Klement's excellent article in the ProVIP section of
the "System iNetwork Programming Tips" February 8, 2007 edition. Scott
advocates a similar architecure for ending programs gracefully during a
*CNTRLD shutdown. Scott, however, uses SIGTERM for this. In tyhat article
Scott listed a set of signals that can be sent/received. I had only really
used SIGALARM before.
 
FINALLY My question is this: We had to send an escape message to the program
to force it off the READ (and as the device is not in a state to write to we
have to close it and re-open it). Is there a signal type, which when sent,
will interrupt the screen I/O? In sockets programming using this method will
cause EINTERRUPT. Is there an equivalent when interacting with a display
device in RPG?
 
Cheers
 
Larry Ducie 
   

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.