• 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

    October 4, 2002 Timothy Prickett Morgan

    Dear Readers:

    In the September 27 issue of Midrange Guru, my friend Holley Davis shared one method for returning the cursor location to a CL program. In this issue he shares a second method.

     

    — Howard

    There are two ways to tell where the cursor is located in a CL program. Both of them require you to add the RTNCSRLOC keyword to your display file as shown in the example below.

    The RTNCSRLOC has two formats. You can use either one or both as needed. One format uses three variables to relay information from the display file to the program about the current position of the cursor in terms of the Record Format Name in which the cursor is located, the Field Name where the cursor is located, and Position of the cursor in the field. That is the format I shared with you in the September 27 issue of Midrange Guru.

    The other format uses two to four variables to return the ROW and COLUMN of the cursor. The first ROW/COL set is the cursor position based on the first usable position on the screen, normally 1/1. The second ROW/COL set is used for window processing and is the cursor position based on the first useable position in the window.

    My original response to this question only included the first format method. The reader asking the question, Larry, pointed out that he needed the row/column to interface with an existing help program. I have updated the examples to include both methods.

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

    Test Display File
    A*       TESTDSPF - 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                                      CF03(03)                         
    A                                      CF06(06)                         
    A* Screen format                                                        
    A*                                                                      
    A          R RCD01                                                      
    A                                      RTNCSRLOC(&CSRRCD &CSRFLD &CSRPOS 
    A                                      RTNCSRLOC(*WINDOW &ROW &COL)     
    A            CSRRCD        10A  H                                       
    A            CSRFLD        10A  H                                       
    A            CSRPOS         4S 0H                                       
    A            ROW            3S 0H                                       
    A            COL            3S 0H                                       
    A                                  1  2'TESTPGM'                        
    A            TITL1         30A  O  1 27
    A                                  1 72DATE                             
    A                                      EDTCDE(Y)                        
    A                                  3  3'Put the cursor in a field and'  
    A                                      COLOR(BLU)                       
    A                                  3 33'press Enter.'                   
    A                                      COLOR(BLU)                       
    A                                  5  3'Field One . . . . . . :'        
    A            RECFLD1       10A  B  5 27                                 
    A                                  6  3'Field Two . . . . . . :'        
    A            RECFLD2        5S 0B  6 27                                 
    A                                  7  3'Field Three . . . . . :'        
    A            RECFLD3       10A  B  7 27                                 
    A                                 23  2'F3=Exit  F6=Window Test'        
    A                                      COLOR(BLU)                       
    A            RETURN1       70A  O  8  3                                 
    A            RETURN2       70A  O  9  3                                 
    A* Now add a window to the mix                                          
    A          R WND01                                                      
    A  *DS3                                WINDOW(10 05 11 70)              
    A  *DS4                                WINDOW(10 05 11 70)
    A  *DS4                                WINDOW(10 05 11 70)             
    A                                      OVERLAY                         
    A                                      RTNCSRLOC(&CSRRCD &CSRFLD &CSRPOS
    A                                      RTNCSRLOC(*WINDOW &ROW &COL -   
    A                                       &ROWW &COLW)                   
    A            CSRRCD        10A  H                                      
    A            CSRFLD        10A  H                                      
    A            CSRPOS         4S 0H                                      
    A            ROW            3S 0H                                      
    A            COL            3S 0H                                      
    A            ROWW           3S 0H                                      
    A            COLW           3S 0H                                      
    A                                  1  2'TESTWND'                       
    A            TITL1         30A  O  1 27                                
    A                                  1 52DATE                            
    A                                      EDTCDE(Y)                       
    A                                  3  3'Put the cursor in a field and' 
    A                                      COLOR(BLU)                      
    A                                  3 33'press Enter.'                  
    A                                      COLOR(BLU)                      
    A                                  5  3'Field One . . . . . . :'
    A            WINFLD1       10A  B  5 27                         
    A                                  6  3'Field Two . . . . . . :'
    A            WINFLD2        5S 0B  6 27                         
    A                                  7  3'Field Three . . . . . :'
    A            WINFLD3       10A  B  7 27                         
    A            RETURN3       65A  O  8  3                         
    A            RETURN4       65A  O  9  3                         
    A                                 10  2'F3=Exit  F6=Screen Test'
    A                                      COLOR(BLU)
    Test CL Program
    /* 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)                    
                 DCL        VAR(&ROWA) TYPE(*CHAR) LEN(3)                   
                 DCL        VAR(&COLA) TYPE(*CHAR) LEN(3)                   
                 DCL        VAR(&ROWB) TYPE(*CHAR) LEN(3)                   
                 DCL        VAR(&COLB) TYPE(*CHAR) LEN(3)                   
                 DCLF       FILE(TESTDSPF) RCDFMT(RCD01 WND01)              
                                                                            
       /* Send screen to display and wait for user to press something.      
     RCD:        SNDRCVF    RCDFMT(RCD01)                                   
                                                                            
       /* End program if F3 pressed.                                        
                 IF         COND(&IN03) THEN(GOTO CMDLBL(END))              
                 IF         COND(&IN06) THEN(GOTO CMDLBL(WND))              
                                                                            
       /* Convert the numeric Position return to Alpha for display.         
                 CHGVAR     VAR(&POS) VALUE(&CSRPOS)
                 CHGVAR     VAR(&ROWA) VALUE(&ROW)                          
                 CHGVAR     VAR(&COLA) VALUE(&COL)                          
                                                                            
       /* Report where the cursor is located.                               
                 CHGVAR     VAR(&RETURN1) VALUE('The cursor is in Format +  
                              - ' *CAT &CSRRCD *BCAT ', Field - ' *CAT +    
                              &CSRFLD *BCAT 'at Pos - ' *CAT &POS)          
                 CHGVAR     VAR(&RETURN2) VALUE(' Display Row/Col is' +     
                              *BCAT &ROWA *CAT '/' *CAT &COLA)              
                 GOTO       CMDLBL(RCD)                                     
                                                                            
       /* Send Window to display and wait for user to press something.      
     WND:        SNDRCVF    RCDFMT(WND01)                                   
                                                                            
       /* End program if F3 pressed.                                        
                 IF         COND(&IN03) THEN(GOTO CMDLBL(END))              
                 IF         COND(&IN06) THEN(GOTO CMDLBL(RCD))              
                                                                            
       /* Convert the numeric Position return to Alpha for display.         
                 CHGVAR     VAR(&POS) VALUE(&CSRPOS)
                 CHGVAR     VAR(&ROWA) VALUE(&ROW)                         
                 CHGVAR     VAR(&COLA) VALUE(&COL)                         
                 CHGVAR     VAR(&ROWB) VALUE(&ROWW)                        
                 CHGVAR     VAR(&COLB) VALUE(&COLW)                        
                                                                           
       /* Report where the cursor is located.                              
                 CHGVAR     VAR(&RETURN3) VALUE('The cursor is in Format + 
                              - ' *CAT &CSRRCD *BCAT ', Field - ' *CAT +   
                              &CSRFLD *BCAT 'at Pos - ' *CAT &POS)         
                 CHGVAR     VAR(&RETURN4) VALUE(' Display Row/Col is' +    
                              *BCAT &ROWA *CAT '/' *CAT &COLA *BCAT +      
                              'Window Row/Col is' *BCAT &ROWB *CAT '/' +   
                              *CAT &COLB)                                  
                 GOTO       CMDLBL(WND)                                    
                                                                           
     END:        ENDPGM
    

    Sponsored By
    RJS SOFTWARE SYSTEMS

    Implement Document Imaging on your iSeries-AS/400 in 30 minutes or less

    Image Server/400 is a Web browser-based document image management system for the iSeries.

    Documents can be quickly scanned and stored in IFS folders, and then located and retrieved for viewing via any Web browser. Integrate with other iSeries-AS/400 applications.

    Visit us at COMMON, Booth 418, call us at 888-RJS-SOFT, or download a FREE fully functional demo from our Web site at

    www.rjssoftware.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: mgo_rc, Volume 2, Number 76 -- October 4, 2002

    Sponsored by
    Midrange Dynamics North America

    With MDRapid, you can drastically reduce application downtime from hours to minutes. Deploying database changes quickly, even for multi-million and multi-billion record files, MDRapid is easy to integrate into day-to-day operations, allowing change and innovation to be continuous while reducing major business risks.

    Learn more.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    When Good Batch FTP Users Go Bad Reader Feedback and Insights: QTEMP and the Library List

    Leave a Reply Cancel reply

MGO Volume: 2 Issue: 76

This Issue Sponsored By

    Table of Contents

    • Reader Feedback and Insights: A Timely OPNQRYF Tip
    • Find the Cursor Position in a CL Program
    • David’s Choice for Java Error Logging

    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