Auto Refresh DSPFIL

From 2EWiki

Jump to: navigation, search


Auto Refresh in a DSPFIL function

This technique describes a way to define auto-refresh for a display file function. You set it up once within the function, each GEN will apply the refresh code. You never need to worry about it again or remember to change something.

Note that details of a revised technique have been posted on at the following location:

The way it works

When you override the WAITRCD on a DSPF, 2e generates code to call a program called Y2WSTOC. This technique relies on the fact that 2e creates two RPG lines (the call line and a parm line) that we can replace. These two lines have been generated on every new release of 2e.

Replace Y2WSTOC

A program is called between the GEN phase and the compile phase. This program is created just once and is used for all instances of auto-refresh. It's purpose is to replace the two redundant 2e lines;

line 1 - replace the Y2WSTOC call with code to set the 2e refresh flag to "Y"
line 2 - replace the PARM opcode with a LEAVE opcode.

User Source

A piece of user source is needed for each auto-refresh DSPFIL. this user source contains pre-compile directives to called the program described above. By calling this excusrsrc within the intialize section of the display function, the auto-refresh code will always be included in your generated RPG source.

To recap

The technique is more difficult to describe than to use.

Having created the "PRETIMOUT" program, there's only three things you need to do add auto-refresh to a function.

1. Change the overrides in the DSPF, set the waitrcd to something other than *nomax.            .
2. Create 3 line user source, unique for the function, that contains the pre-compile directives .
    See example below, replace the MYDSPF with the name of the RPG source name for your DSPFIL  . 
3. place the excusrsrc in the "Initialize" section of your function                             . 


You have a DSPFIL function called "MYDSPF" Change the display file to WAITRCD(30) (ie 30 second refresh)

You create a user source with the following lines

    Y* CALL PRETIMEOUT              
    Y* DLTOVR *ALL   

This user source is placed in the initialize program section of MYDSPF

The RPG program PRETIMEOUT needs to be created once and look like this

    FQRPGSRC UP  E                    DISK
    F            QRPGSRC                           KRENAMEQRPGFT
    IXSRC        DS                             80
    I                                        6   6 COL6
    I                                        7   7 COMMNT
    I                                       28  60 TEXT1
    I                                       34  40 W2PGM
    I              'Y2WSTOC'             C         TOUT
    I              'MOVELY       W0R-C         NEWLN1
    I              'SF'
    I              'LEAVE'               C         NEWLN2
    C                     MOVELSRCDTA    XSRC
    C           *IN01     IFEQ *ON
    C                     SETOF                     01
    C                     MOVEL*BLANK    XSRC
    C                     MOVE 'C'       COL6
    C                     MOVELNEWLN2    TEXT1
    C                     MOVELXSRC      SRCDTA
    C                     UPDATQRPGFT
    C                     ENDIF
    C           TOUT      IFEQ W2PGM
    C                     SETON                     01
    C                     MOVEL*BLANK    XSRC
    C                     MOVE 'C'       COL6
    C                     MOVELNEWLN1    TEXT1
    C                     MOVELXSRC      SRCDTA
    C                     UPDATQRPGFT
    C                     ENDIF
Personal tools