Wednesday, May 1, 2019

Conditioning display file size

24x80 *ds3 and 27x132 *ds4 display size

In the past couple of week I have been asked by several people how to condition whether a display file is shown in *DS3 (24 rows x 80 columns) or *DS4 (27 x 132) format. Rather than writing the same message to each one, I have decided to write this post so I can direct them to it.

These days I doubt if any of us IBM i developers are still using "dumb" workstations, we are all using PCs. In the settings of our 5250 emulator there is a configuration setting so we can set our emulated session to have a screen size of either 24x80 or 27x132. Personally I always configure my sessions to be 27x132.

You can see, and change, this setting depending on the emulator application you use.

Application Steps
ACS Communication > Configure... > Change value in "Screen Size"
Client Access Communication > Configure... > Change the value in "Size"

In a previous post I gave an example of how to tell whether a session was configured as *DS3 or *DS4. In this post I am going to show what code you can insert into your display file and RPG program to control which format the user sees.

In these examples I am going to want to show the screen record format as *DS4 as my default. This I can set in the record level keywords of my display file:

AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++
A                                      DSPSIZ(27 132 *DS4
A                                             24 80 *DS3)

The only reason I have broken this out into two lines is so I can show it in the space offered by the web editor. I could have equally well enter what is shown below.

Functions+++++++++++++++++++++
DSPSIZ(27 132 *DS4 24 80 *DS3)

In that previous post I showed how to use SDA to add the *DS3 and *DS4 to a display file.

Below is a simple display file that can be used in either size format.

   AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions+++++++++
01 A                                      DSPSIZ(27 132 *DS4
02 A                                             24 80 *DS3)
03 A                                      INDARA
    *-------------------------------------------------------
04 A          R SCREEN1
05 A                                  1 90'SCREEN1'
06 A  *DS3                            4  3 
    *-------------------------------------------------------
07 A          R SCREEN2
08 A  99                                  DSPMOD(*DS3)
09 A                                  1  3'DS3 indicator .'
10 A            ZINDICATOR     1A     1 20
11 A                                  3  3'SCREEN2'

Line 1 and 2: The default display size is *DS4. If, due to the PC's configuration, *DS4 cannot be used the display will use *DS3.

Kline 3: The INDARA keyword is needed as I always use the indicator data structure in my RPG programs.

Lines 4 – 6: In this record format the text "SCREEN1" will be display on the first row and in the 90th column, which is outside of the display range of *DS3. Line 6 will ensure that if the display is being used in *DS3 "SCREEN1" will be displayed on the fourth row and in the third column.

Lines 7 – 11: The second record format, SCREEN2, can be displayed in both *DS3 and *DS4 on a *DS4 compatible session.

Line 8: If indicator 99 is on the record format will be displayed as *DS3 due to the value in the DSPMOD keyword. If 99 is off then the record format will be displayed in whatever the session's default size format is. I do not have to condition this keyword with an indicator. If the indicator was absent then the record format would always be displayed as *DS3.

Lines 9 and 10: Is used to display the value of indicator 99.

I am only going to show snippets of the RPG code.

01  dcl-f DSPFILE1 workstn indds(Dspf) ;

02  dcl-ds Dspf qualified ;
03    ScreenSize ind pos(99) ;
04  end-ds ;

Line 1: The display file is defined to use the indicator data structure.

Lines 2 – 4: The indicator data structure just contains one indicator, 99, which corresponds to the indicator used for the DSPMOD.

The line below, 5, displays the first record format.

05  exfmt SCREEN1 ;

Depending upon which screen size format my display looks like:


Click on image to see a larger version

The session on the right, black, is configured at 27x132 (*DS4), therefore, the text, "SCREEN1", is shown in the 90th column. While the display on the left, blue, is configured at 24x80 (*DS3), and shows "SCREEN1" at the location given on line 5 of the display file, fourth column and third row.

In the second display record format the screen size is conditioned by the indicator 99, or Dspf.ScreenSize in the RPG program. If I always wanted this one record format to display at *DS3 regardless of my configuration I would still use the DSPMOD(*DS3), but without the conditioning indicator.

06  Dspf.ScreenSize = *off ;
07  ZINDICATOR = Dspf.ScreenSize ;
08  exfmt SCREEN2 ;

When 99, Dspf.ScreenSize, is off the record format is displayed with my display's default record format.


Click on image to see a larger version

As the display on the left is configured as 24x80 it displays the record format as *DS3. The right is configured as 27x132 and displays the record format as *DS4.

In this next example I have turned 99, Dspf.ScreenSize, on.

09  Dspf.ScreenSize = *on ;
10  ZINDICATOR = Dspf.ScreenSize ;
11  exfmt SCREEN2 ;

Both sessions show the display as *DS3.


Click on image to see a larger version

The people who asked me about this also asked how they could position fields in different places on the display depending on the screen size, and have different size fields displayed. I advised them to try to do both their *DS3 and *DS4 in the same record format would lead to a mess, and make it hard to maintain.

What I advised was to have two record formats, one for each configuration. If I determine the screen size I can then display one record format or another. If I used the same function key indicators and field names on both record formats, unless the fields are different sizes, most of the validation and processing would be the same.

01  dcl-f DSPFILE workstn infds(InfDs) ;

02  dcl-ds InfDs qualified ;
03    Rows int(5) pos(152) ;
04    Columns int(5) pos(154) ;
05  end-ds ;

06  dcl-s SmallScreen ind ;


07  if (InfDs.Rows = 24) ;  //*DS3 24x80
08    SmallScreen = *on ;
09  endif ;


10  if (SmallScreen) ;
11    exfmt SCREEN1 ;
12  else ;
13    exfmt SCREEN2 ;
14  endif ;

Line 1: The definition for the display includes the definition for the file information data structure, INFDS.

Lines 2 – 5: I am only concerned with two subfields of the file information data structure, the ones that return the size of the configured display.

Line 6: I am going to use this indicator variable to flag which size display is configured.

Lines 7 – 9: If the display is configured to *DS3, 24 rows x 80 columns, I set on to the indicator SmallScreen.

Lines 10 – 14: I can then use this indicator to condition which record format is displayed. SCREEN1 is designed for *DS3, and SCREEN2 for *DS4.

In conclusion it is possible to create a display file that will work well for both screen size configurations. You just have to be careful and take your time not to create a mess by stuffing everything into one record format.

 

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

5 comments:

  1. Somehow I always run into issues with 80 col and 132 col screens resulting in CPF4169 errors. A while ago I created that environment variable recommended in this post: https://www.rpgpgm.com/2018/08/using-environmental-variables.html and quickly removed it when I ran into issues debugging an 80 col screen while in a 132 col debug session. 80 and 132 screens never seem to get along. The issue seems to occur when you invoke a 80 col screen from a 132 col screen but I've never quite gotten to the bottom of it. The message text for CPF4169 is not particularly accurate or helpful when that error occurs as a result of using both screen sizes at the same time. Message . . . . : The device file does not contain an entry for screen size.
    Cause . . . . . : The file &2 in library &3 display size (DSPSIZ) parameter value is not the screen size of the device &4.
    Recovery . . . : Close the file. Change the DSPSIZ parameter value. Create the file again, and then try the command again.

    Maybe a good subject for a future post: CPF4169 De-mystified. If I recall correctly, setting that environment variable and then debugging an 80 Col screen in green-screen will do it.

    ReplyDelete
    Replies
    1. I just used the feedback area related to file WORKSTN, position 152-153 binary for Rows, position 154-155 binary for Columns, if the device supports 132 Columns we found 27 and 132 in the 2 binary fields.
      If so in my pgm I enable a Fxx key to switch from 80 to 132 Columns andò vice. To manage the DSPF in easier way...you van use 2 different format of the dame screen, one with 80 Columns andò the other zone with 132 Columns

      DinoB

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. One of the issues I have come across is that if it a full screen display file you will get that CPF4169 error if there is an 'ASSUME' type record format. I have always just deleted that format and then it works.
    On pop-up screens (just windows not full screens) then you have to specify the DSPMOD on every record format except the ASSUME record or the SFL record

    ReplyDelete
  4. I've used my *DS4 pretty often but one thing I've never been able to do is display a sub-file to be displayed in a window on a wide screen. It keeps rejecting with WINDOW size values on the WINDOW record format.

    ReplyDelete

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.