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 - 4119 days ago
Last viewed on: 04 May 2024 (16761 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.

Thanks!

Chris

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

COMMENTS

(Sign in to Post a Comment)
Posted by: DaleB
Premium member *
Reading, PA
Comment on: Positioning the cursor in a display
Posted: 11 years 10 months 11 days 14 hours 56 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: 11 years 10 months 11 days 13 hours 39 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: 11 years 10 months 7 days 15 hours 39 minutes ago
Edited: Thu, 28 Jun, 2012 at 06:19:42 (4328 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: 11 years 8 months 19 days 17 hours 41 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: 11 years 8 months 2 days 12 hours 26 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                                                        
                            CF04                            
                            RTNCSRLOC(&£FORM &£FIELD)       
                            RTNCSRLOC(*MOUSE &NUMLIG &NUMPOS)
                            CSRLOC(NUMLIG     NUMPOS)       
  £FORM        10A  H                                      
  £FIELD        10A  H                                      
  NUMLIG       3S 0H                                      
  NUMPOS      3S 0H