Wednesday, June 17, 2020

Control progression of cursor in display file

control cursor movement on dspf

The question was how to control the way the cursor moves from field to field on a display. The display had two columns of fields and the questioner wanted the cursor to progress down the first column's fields before moving to the top of the second column.

My example display file contains two records format. The first I will be using to demonstrate the default cursor progression, and the second how I can move down the first column's fields before moving over to the second column.

The DDS code for the first record format looks like:

A          R SCREEN0
A            Z001           3   B  2  3
A            Z002           3   B  2 10
A            Z003           3   B  3  3
A            Z004           3   B  3 10
A            Z005           3   B  4  3
A            Z006           3   B  4 10

I compile the display file. I do not need a write a program to show this display file I can use the Start SDA command, STRSDA, to test the display file without a program.

STRSDA OPTION(3) SRCFILE(MYLIB/DEVSRC) SRCMBR(TESTDSPF)

When I display the record format it looks like:

  1        2  
  3        4  
  5        6  

If I press the Tab or Field Exit key the cursor goes:

1 → 2 → 3 → 4 → 5 → 6 → 1

That is not the progression I want.

Fortunately there is a DDS keyword FLDCSRPRG, Cursor Progression Field, that I can add to "tell" my display where I want the cursor to go next.

The second record format's fields have the same names, and have the FLDCSRPRG keyword followed by the next field in parentheses:

A          R SCREEN1
A            Z001           3   B  2  3FLDCSRPRG(Z003)
A            Z002           3   B  2 10FLDCSRPRG(Z004)
A            Z003           3   B  3  3FLDCSRPRG(Z005)
A            Z004           3   B  3 10FLDCSRPRG(Z006)
A            Z005           3   B  4  3FLDCSRPRG(Z002)
A            Z006           3   B  4 10

After compiling the display file again, I then use STRSDA command and display record format SCREEN1.

The screen looks the same as the previous record format. This time when I press the Tab or Field Exit key the cursor goes down the first column and then to the top of the second column:

1 → 3 → 5 → 2 → 4 → 6 → 1

There are some limitations on how I can use this keyword:

  • The field that this is used with must be input capable (= "input only" and "both" fields).
  • The To field must be in the same record format.
  • Cannot condition this keyword with indicators.
  • Cannot be used with a field that is defined with SNGCHCFLD or MLTCHCFLD keyword.

 

You can learn more about the FLDCSRPRG display file keyword from the IBM website here.

 

This article was written for IBM i 7.4, and should work for some earlier releases too.

1 comment:

To prevent "comment spam" all comments are moderated.
Learn about this website's comments policy here.

Some people have reported that they cannot post a comment using certain computers and browsers. If this is you feel free to use the Contact Form to send me the comment and I will post it for you, please include the title of the post so I know which one to post the comment to.