• 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
    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

    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

    • Tool Aims To Streamline Git Integration For Old School IBM i Devs
    • IBM To Add Full System Replication And FlashCopy To PowerHA
    • Guru: Decoding Base64 ASCII
    • The Price Tweaking Continues For Power Systems
    • IBM i PTF Guide, Volume 27, Numbers 31 And 32
    • You Can Now Get IBM Tech Support For VS Code For i
    • Price Cut On Power S1012 Mini Since Power S1112 Ain’t Coming Until 2026
    • IBM i: Pro and Con
    • As I See It: Disruption
    • IBM i PTF Guide, Volume 27, Number 30

    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