• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Find the Cursor Position in a CL Program

    September 27, 2002 Timothy Prickett Morgan

    Hey, Howard:

    At my shop, we have field on-line help in our RPG programs that allows the user to place the cursor on a field, then press F1 and get help for that field. The RPG passes row and column data to the help text program to accomplish this. Is there way to capture row and column in a CL program to accomplish the same thing? Currently, we get a help text-screen that covers the entire screen, not just the field that the cursor is on.

    — Larry

    My friend Holley Davis can help you with this one, Larry. Here’s his solution.

    — Howard

    The cursor location you are getting from your RPG programs comes from the file information data structure (INFDS) for the display file in the Display Specific Feedback Information area. This information is not available to a CL program.

    However, there are two ways to tell where the cursor is in a CL program. One is based on row and column, the other on field name. The field-name method is preferable because system maintenance is easier. That is, if you move a field, the help information doesn’t have to be adjusted. I will cover the field-name method now and show you the row/column method in an upcoming issue of Midrange Guru.

    Add the RTNCSRLOC keyword to your display file as shown in the example below:

    A*      TEST5DSPF - Test display file to demonstrate how to use
    A*                  the RTNCSRLOC keyword to determine where the
    A*                  the cursor is on the screen in a program.
    A*                                                               
    A                                      DSPSIZ(24 80 *DS3 -
    A                                             27 132 *DS4)
    A                                      PRINT
    A* Screen format 
    A* 
    A*  The RTNCSRLOC uses three variables to relay information      
    A*  from the display file to the program about the current       
    A*  position of the cursor.                                      
    A*       Record Format Name                                      
    A*       Field Name                                              
    A*       Position of the cursor in the field.                    
    A*                                                               
    A          R RCD01                                               
    A                                      CF03(03)                  
    A                                      RTNCSRLOC(&CSRRCD &CSRFLD &CSRPOS)
    A            CSRRCD        10A  H                                        
    A            CSRFLD        10A  H                                        
    A            CSRPOS         4S 0H                                        
    A                                  1  2'TESTPGM'                         
    A            TITL1         30A  O  1 27                                  
    A                                  1 72DATE                              
    A                                      EDTCDE(Y)                         
    A                                  4  3'Put the cursor in a field and'   
    A                                      COLOR(BLU)                        
    A                                  4 33'press Enter.'                    
    A                                      COLOR(BLU)                        
    A                                  6  3'Field One . . . . . . :'         
    A            FIELD1        10A  B  6 27                                  
    A                                  7  3'Field Two . . . . . . :'         
    A            FIELD2         5S 0B  7 27                                  
    A                                  8  3'Field Three . . . . . :'         
    A            FIELD3        10A  B  8 27                                  
    A            RETURN        70A  O 10  2          
    A                                 23  2'F3=Exit' 
    A                                      COLOR(BLU)
    

    The RTNCSRLOC uses three variables to relay information from the display file to the program regarding the current position of the cursor. These variables return the record format name in which the cursor is located, the field name in which the cursor is located, and the position of the cursor in the field.

    Use the following CL program to test this display file technique for yourself:

       /* Test program to demonstrate how to use RTNCSRLOC to locate        */  
       /* where the cursor is on the screen.                                */  
                                                                                
                 PGM                                                            
                                                                                
                 DCL        VAR(&POS) TYPE(*CHAR) LEN(4)                        
                 DCLF       FILE(TEST5DSPF)                                     
                                                                                
       /* Send screen to display and wait for user to press something.      */  
    LOOP:       SNDRCVF                                                        
                                                                                
       /* End program if F3 pressed.                                        */  
                 IF         COND(&IN03) THEN(GOTO CMDLBL(END))                  
                                                                                
       /* Convert the numeric Position return to Alpha for display.         */  
                 CHGVAR     VAR(&POS) VALUE(&CSRPOS)                            
                                                                                
       /* Report where the cursor is located.                               */  
                 CHGVAR     VAR(&RETURN) VALUE('The cursor is in +              
                              Format -' *cat &CSRRCD *bcat ', Field -' *cat +   
                              &CSRFLD *BCAT 'at Pos-' *cat &POS)                
                                                                                
                 GOTO       CMDLBL(LOOP)                                        
                                                                                
     END:        ENDPGM                                                         
    

     

    I hope this helps.  

    — Holley Davis
    Davis Software Services, Inc.
    www.fad400.com
    888-288-6676

    Sponsored By
    COMMON

    COMMON IT EXECUTIVE CONFERENCE

    Tell your IT Directors about the three-day event that is specially designed for them. Held October 13-15, 2002, in Denver, the IT Executive Conference will give iSeries Directors the opportunity to network and learn from well-known speakers in the iSeries environment, and receive new strategies for optimizing operations.

    To find out more, go to: http://www.common.org/executive

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: mgo_rc, Volume 2, Number 74 -- September 27, 2002

    Sponsored by
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    OPNQRYF Date Arithmetic Reader Feedback and Insights: Displaying Menu Options

    Leave a Reply Cancel reply

MGO Volume: 2 Issue: 74

This Issue Sponsored By

    Table of Contents

    • Reader Feedback and Insights:
    • Loading a Tilde-Delimited File into the Database
    • Find the Cursor Position in a CL Program

    Content archive

    • The Four Hundred
    • Four Hundred Stuff
    • Four Hundred Guru

    Recent Posts

    • Meet The Next Gen Of IBMers Helping To Build IBM i
    • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
    • Will Independent IBM i Clouds Survive PowerVS?
    • Now, IBM Is Jacking Up Hardware Maintenance Prices
    • IBM i PTF Guide, Volume 27, Number 24
    • Big Blue Raises IBM i License Transfer Fees, Other Prices
    • Keep The IBM i Youth Movement Going With More Training, Better Tools
    • Remain Begins Migrating DevOps Tools To VS Code
    • IBM Readies LTO-10 Tape Drives And Libraries
    • IBM i PTF Guide, Volume 27, Number 23

    Subscribe

    To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

    Pages

    • About Us
    • Contact
    • Contributors
    • Four Hundred Monitor
    • IBM i PTF Guide
    • Media Kit
    • Subscribe

    Search

    Copyright © 2025 IT Jungle