IBM Support

ILE RPG Example of Screen Auto-Refresh and Alarm Usage

Troubleshooting


Problem

This document illustrates the design of screens with auto-refresh and the alarm feature. Auto-refresh may be used, for example, when the application driving the screen is expected to reset the screen's appearance after some inactivity time-out.

Resolving The Problem

This document illustrates the design of screens with auto-refresh and the alarm feature. Auto-refresh may be used, for example, when the application driving the screen is expected to reset the screen's appearance after some inactivity time-out. The time-out interval can be controlled when compiling the display file's DDS. The WAITRCD parameter of the CRTDSPF command is set to N seconds, where N is the number of seconds to wait before refreshing the screen. The alarm can, among other things, be conditioned with indicators to set it on or off.

The ILE RPG sample program in this document features auto-refresh and toggles alarm on/off using function key F4.

DDS for DSPF timedspf:
     A* To activate auto-refresh for this DSPF, compile using:      
     A* CRTDSPF WAITRCD(N)                                          
     A* where N = number of seconds to wait before refreshing.      
     A* For example:                                                
     A* CRTDSPF WAITRCD(1)                                          
     A* refreshes every second, giving a real-time clock.            
     A*                                                              
     A                                      DSPSIZ(*DS3)            
     A                                      CF03(03  'EXIT')        
     A                                      CF04(04  'ALARM ON/OFF')
     A                                      INVITE                  
     A          R SCN1                                              
     A  05                                  ALARM                    
     A                                  5 10'CURRENT TIME:'          
     A                                  5 30TIME                    
     A                                      COLOR(RED)              
     A                                  7 10'USER INPUT:'            
     A            FLD1          10A  B  7 30COLOR(WHT)              
     A                                 24 10'F3=End Program'        
     A                                 24 40'F4=Toggle Alarm On/Off' 

ILE RPG Source:
     Ftimedspf  cf   e             workstn maxdev(*file)
      *
      * start with alarm off
      *
       *in05 = *off;

      * do until user presses <F3> to exit
      *
       dou *in03 = *on;

      * write to screen
      *
         write scn1;

      * read user data, if any
      //
         read(E) timedspf;
         *IN99 = %ERROR;

      * if user wants to toggle alarm
      *
         if *in04 = *on;

      * turn toggle indicator off
      *
           *in04 = *off;

      * toggle alarm
      *
           *in05 = not(*in05);
         endif;
       enddo;
       *inlr = *on;   

[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CHtAAM","label":"Programming ILE Languages"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Historical Number

19482740

Document Information

Modified date:
14 January 2025

UID

nas8N1017777