Hola,
Prueba esto que me enviaron, funciona perfectamente:
3. AUTOMATICALLY REFRESHING SCREENS
Q: Is it possible to have a screen that updates on its own without the
user having to press a key?
A: Yes! A display file with a data queue attached to it is a great way
to do this.
A normal EXFMT statement writes to a display and then immediately
reads it. It's this read that causes the system to wait until the user
presses Enter. If you write to the display with the WRITE opcode, your
program will keep running without waiting for the user's input.
To optimize the number of times data needs to be transferred to and
from the terminal, the iSeries normally does not display the screen
until you request input. The DDS keyword FRCDTA is used to override
this behavior; when you specify FRCDTA, the screen displays as soon as
it's written.
How can you get input from the screen so that you can still use F3 to
exit the program? That's where the data queue comes in. When your
screen format contains the INVITE keyword, the system will unlock the
keyboard when the screen is written. Then, if the user presses Enter
or a function key, an entry will be written to the data queue.
As long as you read the screen only after receiving an entry from the
data queue, your program will never get stuck waiting for a user to
press a key.
Here is sample code that demonstrates this technique. It displays the
time on the screen, updating it every second. If the user presses
Enter or a function key, it will read the screen. If the function key
happens to be F3, the program will stop; otherwise, it keeps
displaying the time.
DDS source for display file:
A DSPSIZ(24 80 *DS3)
A R AUTOREFS1
A CF03
A FRCDTA
A INVITE
A 11 30'The time is:'
A THETIME 8 O 11 43
A 23 2'F3=Exit'
ILE RPG source:
* Demonstration of automatically refreshing the screen on a timed
* interval.
* Scott Klement, Jan 15, 2004
*
* To compile:
* CRTDSPF FILE(AUTOREFS) SRCFILE(mylib/QDDSSRC)
* CRTBNDRPG AUTOREF SRCFILE(mylib/QRPGLESRC) DBGVIEW(*LIST)
*
FAUTOREFS CF E WORKSTN USROPN
D QCMDEXC PR ExtPgm('QCMDEXC')
D Command 32702A const options(*varsize)
D Length 15P 5 const
D QRCVDTAQ PR ExtPgm('QRCVDTAQ')
D dataq 10A const
D dqlib 10A const
D maxlen 5P 0
D data 80A
D wait 5P 0 const
D Cmd s 1000A varying
D dqLen s 5P 0
D dqdata s 80A
D TimeFld s T
c exsr AttachDtaQ
c dou *INKC = *ON
c time TimeFld
c *HMS move TimeFld TheTime
c write AUTOREFS1
c eval dqlen = %size(dqdata)
c callp QRCVDTAQ('AUTOREFQ': 'QTEMP': dqLen:
c dqData: 1)
c if dqlen > 0
c read(e) AUTOREFS1
c endif
c enddo
c exsr DetachDtaQ
c eval *inlr = *on
*=================================================================
* Attach a data queue to the display file
*=================================================================
Csr AttachDtaQ begsr
*------------------------
c eval Cmd = 'DLTDTAQ DTAQ(QTEMP/AUTOREFQ)'
c callp(e) QCMDEXC(Cmd: %len(Cmd))
c eval Cmd = 'CRTDTAQ DTAQ(QTEMP/AUTOREFQ)' +
c 'MAXLEN(80)'
c callp QCMDEXC(Cmd: %len(Cmd))
c eval Cmd = 'OVRDSPF FILE(AUTOREFS) ' +
c 'DTAQ(QTEMP/AUTOREFQ)'
c callp QCMDEXC(Cmd: %len(Cmd))
c open AUTOREFS
*------------------------
Csr endsr
*=================================================================
* Detach the data queue from the display file
*=================================================================
Csr DetachDtaq begsr
*------------------------
c close AUTOREFS
c eval Cmd = 'DLTOVR FILE(AUTOREFS)'
c callp QCMDEXC(Cmd: %len(Cmd))
c eval Cmd = 'DLTDTAQ DTAQ(QTEMP/AUTOREFQ)'
c callp(e) QCMDEXC(Cmd: %len(Cmd))
*------------------------
Csr endsr
Saludos.
Jordi Carreras
Jes�s Manuel S�nchez
<[EMAIL PROTECTED] Para: "foro400" <[EMAIL
PROTECTED]>
es.es> cc:
Enviado por: Asunto: Actualizaci�n autom�tica
hora sistema en pantalla
forum.help400-request
@combios.es
17/03/2004 13:18
Por favor, responda a
forum.help400
Hola a todos:
Conoceis alguna forma o sabeis de alguna utilidad para la hora del sistema
mostrada en una pantalla de aplicaci�n se actualice autom�ticamente,
independientemente de pulsar intro.
Gracias.
Jes�s M. S�chez Monta�a
Santiago de Compostela
_____________________________________________________
Forum.HELP400 es un servicio m�s de NEWS/400.
� Publicaciones Help400, S.L. - Todos los derechos reservados
http://www.help400.es
_____________________________________________________
Para darte de baja, env�a el mensaje resultante de pulsar
mailto:[EMAIL PROTECTED]