Midrange News for the IBM i Community

Posted by: Chris Proctor
Programmer Analyst
Columbia Sports Company
Portland, OR
Positioning the cursor in a display
has no ratings.
Published: 22 Jun 2012
Revised: 23 Jan 2013 - 3163 days ago
Last viewed on: 20 Sep 2021 (14674 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Positioning the cursor in a display Published by: Chris Proctor on 22 Jun 2012 view comments(5)

Happy Friday! That must be why I'm drawing a blank. I'm using F4 to allow the user to prompt on a number of fields in my dspf (not a sfl) and once they've made their selection from my dropdown window the cursor is returning to the first imput-capable field in the record format. I want the cursor to stay on the prompted field. I can't remember how to do that. I am using RTNCSRLOC in the format to tell me &rcd and &fld.

Any assistance would be greatly appreciated.



Return to midrangenews.com home page.
Sort Ascend | Descend


(Sign in to Post a Comment)
Posted by: DaleB
Premium member *
Reading, PA
Comment on: Positioning the cursor in a display
Posted: 9 years 3 months 9 hours 34 minutes ago

DSPATR(PC), which is position cursor attribute. Need indicators to select where you want it active. If more than one active, it goes to uppermost, leftmost.

The other way is CSRLOC(row-field col-field), where they are both 3S0 hidden fields in the same record format. If both are active, CSRLOC overrides DSPATR(PC).

If you've got a subfile, you can also use SFLRCDNBR(CURSOR), which puts the cursor in the first input-field in the row identified by the SFLRCDNBR field. CSRLOC overrides SFLRCDNBR(CURSOR), too.

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: Positioning the cursor in a display
Posted: 9 years 3 months 8 hours 17 minutes ago

One place I worked wanted the cursor back where you found it after a prompt.  Had to use the csr-x, csr-y method Dale suggests.  However, we did get complaints when someone had the cursor in the middle of the promptable field and that's where I put it back to.  General user concensus was please put the cursor back at the beginning of the field we just prompted - so we changed to using DSPATR(PC).

Posted by: TFisher
Premium member *
Comment on: Positioning the cursor in a display
Posted: 9 years 2 months 27 days 10 hours 17 minutes ago
Edited: Thu, 28 Jun, 2012 at 06:19:42 (3372 days ago)

Consider removing DSPATR(PC) and creating a function to retrieve row/column for a given field and use the CSRLOC keyword to position the cursor. 


My opinion is that DSPATR(PC) should never be used anymore.  There simply is no need to add this type of code to a modern RPG program.

Posted by: melindajwebb
Premium member *
Comment on: Positioning the cursor in a display
Posted: 9 years 1 months 6 days 12 hours 19 minutes ago

I would like to get the code from TFisher for the prRtvRowCol() if at all possible.  Please email me at melindawebb@cableone.net


thank you

Posted by: gopf
Premium member *
Tahiti French Polynesi
Comment on: Positioning the cursor in a display
Posted: 9 years 20 days 7 hours 4 minutes ago

Chris, If you want the cursor to stay on the prompted field, the best way is to use the following DDS keywords , no need to create a function or write code.

First RTNCSRLOC will return the name of the field

Second RTNCSRLOC will return cursor location (&NUMLIG &NUMPOS)

CSRLOC must have same fields name spécified in the second RTNCSRLOC (&NUMLIG &NUMPOS)

R A1                                                        
                            RTNCSRLOC(&£FORM &£FIELD)       
                            RTNCSRLOC(*MOUSE &NUMLIG &NUMPOS)
                            CSRLOC(NUMLIG     NUMPOS)       
  £FORM        10A  H                                      
  £FIELD        10A  H                                      
  NUMLIG       3S 0H                                      
  NUMPOS      3S 0H