There is a facility to link the display of data on a display to a data queue. The system will then notify you through the data queue if data was received from the display device. Have a look at the OVRDSPF command where you specify the data queue name. Your main display program will wait for an entry from the data queue before performing any displays, etc.
Then you write another program that will run at the same time as your display program that will perform the timing for the refresh by posting an entry into that data queue every 30 seconds. Your main program will receive this entry through the data queue and perform a refresh.
The nice thing about this is that you have only one data queue that will drive both events:
1. An entry from the display
2. The 30 second heartbeat
There is however a catch. The data you send to a display device is only physically displayed at the next read (from the dislay). This means that the refreshed data will be a display behind. But there is a solution. Have a look at deferred or no-deferred write when you compile the program. You have to select no-deferred write. This will then force the display of the refreshed data at the time you write to the display. I have used this option before but can’t exactly remember where to specify this. Please do some searching.
What is also nice is that you can now refine the two programs – display and timer – to interact so that when a user enters data from the display the timer is reset to 30 second otherwise you can have a refresh shortly after data was entered.
First, the question is incomplete. What does “the ability to page up and down” have to do with “automatically refresh after a selected period of time“?
It seems like those two elements should not be combined in a single function. If both are available, sooner or later they’re both going to happen at the same time. (In fact, it would seem a regular possibility.) Will the keyboard be buffered? Take care in how you handle active keyboards concurrently with active output.
See Auto refresh screen – Data queue style for one useful example.