Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cursor placement into error fields

Status
Not open for further replies.

breilly

Programmer
Nov 12, 2002
17
US
Does any one know where I can get ideas, or a sample, for creating a common routine that can be included into programs that will control cursor placement.

We have data entry screens and want to position the cursor in the incorrect field, or the 1st one if multiple errors exist and I do not want to continue rewriting this logic program after program.
 
You can use this special-names clause to handle cursor control. This is already coded in the CRTVARS.DEF copy file.

WORKING-STORAGE SECTION.
01 SCREEN-CONTROL IS SPECIAL-NAMES SCREEN CONTROL.
03 ACCEPT-CONTROL PIC 9.
03 CONTROL-VALUE PIC 999.
03 CONTROL-HANDLE USAGE HANDLE.
03 CONTROL-ID PIC X(2) COMP-X.


Then use an 'after procedure' to edit each fields entered data. At that point 'control-value' is set to the id of the field being edited. A common routine that sets accept-control to 1 and then redisplays the screen will put the cursor where you want it.

You could also save the ID's of error fields in a table and code a common routine that uses those values to visit each field in error in turn.

Regards

Vins Nash
 
The tips were great; however, management does not want to use the after procedure. Ergo, I am 'stuck' with the table appraoach and have a follow up questions for 20 points.

I have written a sample program that will edit the entire screen at one time, create a table of which fields are in error along with a field number. I then put the table into a multiple line field, listing the errors. I use the table to find the first field on the screen that has an error and put the cursor on that field.

Every thing is COOL until someone changes the screen and adds a new field (not at the end). My logic then will pull the field in error out of the table, along with the field number and it does not match the changes. So, my question is how can I make the program generic, so the addition of new fields does not require me to change logic. (I am using a hard coded value to reference the field in error). How can I use a variable to determine which field is in error without using the after procedure, which gives me the field number in the special names screen-control?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top