Link to home
Start Free TrialLog in
Avatar of roosterup
roosterup

asked on

How to Restore Cursor Position on next EXFMT in loop

i got this new program that builds an sql statment. users can enter has many values for a field as they like by keying it in and pressing enter.  F8 is  used to submit the job.

as the user is keying in multiple values for a field, i would like for the cursor to return to that field on the next EXFMT, how can I do this?
Avatar of Faiz
Faiz

Condition the field in the display file with an indicator for DSPATR(PC). Turn the indicator on before your EXFMT and the cursor will be positioned on that field.

Hi
The method I use is the using the key words
RTNCSRLOC(*MOUSE &Row &Col)
POSCSR(&Row &COL)
(These would be in the subfile control Format).

To position at the first input field set row to 0 in the RPG/Cobol etc..

Dave
roosterup:

First question is "How does your program know that the user wants to enter another value for that field rather than move to another field?"

Let's say you always want to leave the cursor on whatever field the user typed into last, unless <F8> is pressed and then you want to place the cursor back to the first field. If the users are done entering values for a field, they can <TAB> to the next field. Does that describe what you want?

Tom
Avatar of roosterup

ASKER

>>First question is "How does your program know that the user wants to enter another value for >>that field rather than move to another field?"

Pressing enter is how the program knows the user wants to enter another value. Tab should take you to the next field.


The user should be able to enter values into the same field by pressing enter without tabbing back to that field.  The user will tab to get to the next field.  

As each value is entered, the screen input field is cleared and the value is concatenated to a field that is on the same line as the input field. This is so the user can see all the values he will search for.
roosterup:

Previous replies are useful. Consider the following example of a couple DSPF fields:

00020A            FLDY           3   I  8 30CHANGE(68 'FLDY was entered')
00021A 68                                   DSPATR( PC )
00030A            FLDZ           3   I  9 30CHANGE(69 'FLDZ was entered')
00031A 69                                   DSPATR( PC )

If the user types into FLDY, change indicator 68 comes on. If 68 is on during the next outpt, FLDY is where the cursor should be positioned. If the user types into FLDZ, change indicator 69 comes on. If 69 is on during the next outpt, FLDZ is where the cursor should be positioned.

But what if the user types into FLDY, <TAB>s to FLDZ, and types in FLDZ, presses <Enter> and expects to type another value in FLDZ? Both 68 and 69 will be on. Where should the cursor go?

Obviously to FLDZ, but it will go to FLDY unless your program turns 68 off. This will be true for every field above FLDZ.

Not technically difficult, but requires attention to detail.

What VRM of OS/400 are you working with?

Tom
i'm on v5r2.

so maybe i need to capture the cursor position and then restore it, that possible?
mayankgangrade:

With the record-level keyword RTNCSRLOC(&RCD &FLD &POS), you can get info about the cursor location when the user presses <Enter>. With the record-level keyword CSRLOC(LINNBR POSNBR), you can set the position where the cursor should be on an output operation.

However, when the user presses <Enter>, the cursor might not be in the field that you want to position the cursor in. The user might have typed into FLD1, <Tab> to Fld2, typed in FLD2, then moved back to FLD1 to correct a character. When <Enter> is pressed, the display file will report that the cursor is in FLD1.

You still need to track which fields had data entered into them. Your program logic will need to decide what to do next. The CSRLOC() keyword can be used on output if you don't want to use indicators for DSPATR(PC), but you'll need to keep track of the actual locations of your display fields.

Tom
ASKER CERTIFIED SOLUTION
Avatar of Member_2_276102
Member_2_276102

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial