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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validate key entry(RMCOBOL) 1

Status
Not open for further replies.

SiouxCityElvis

Programmer
Jun 6, 2003
228
US
I didn't know what word to search for in my RMCOBOL Language Ref Manual...

I have a screen for entry/update

I'm on the Update screen and the user selects to view/update a numeric field which I have display on line 23 for them as:

[0000012345] and their prompt is on the first 0.

But what if I want them to have the option to bring this up, but to NOT make any changes to it - in other words they don't want to update this field after all. The only thing I can do is to have them re-type the same value over the value displayed. Otherwise, it will update it with 0000000000 since the ACCEPT accepts a numeric ws field to update the record's numeric field.

I want to be able to
IF Keyboard input = TAB(or SPACEBAR)
then
Leave the field alone and maintain its current value.

Any suggestions?
I know this is probably easy, I just can't find it in the manual anywhere.

Thanks.
-David
 
David,

Can you give an example of the ACCEPT statement, along with the DATA DIVISION items? There are many variations of the ACCEPT statement, so we need more...

Tom Morrison
 
I think I found a solution actually..it seems to work
....
....
Code:
 ELSE IF SELECT-MENU-2 = "08"
    DISPLAY "[" EMP-EMAIL "]" LINE 23
    ACCEPT FIELD-CHANGE LINE 23 POSITION 2
      ON ESCAPE CONTINUE
      NOT ON ESCAPE
         DISPLAY "Escape didn't work"
         ACCEPT MENU-PROMPT
         PERFORM TO-UPPERCASE
      MOVE FIELD-CHANGE TO EMP-EMAIL REWRITE EMP-RECORD
    END-ACCEPT
 
David,

This is on Unix, right? I think you might have your terminal configured incorrectly or something, because you should be able to do something like:
Code:
DISPLAY "[" EMP-EMAIL "]" LINE 23
ACCEPT EMP-EMAIL LINE 23 POSITION 2 UPDATE.

BTW, your indentation would lead me to think that you might have a logic error.

Also, a hint about numeric fields (mentioned in your original post): always use UPDATE unless you determine some very specific reason not to do so.

Tom Morrison
 
My code snippet seemed to provide the solution I was looking for.

I'll look into that UPDATE...so you just use UPDATE EMP-SSN instead of ACCEPT EMP-SSN for numeric fields???
 
This variation of ACCEPT I'm using is for accepting user input from my COBOL interface application.

I'm taking data entry and creating new records in my EMPDB file.

My discovery of using ON ESCAPE and NOT ON ESCAPE works as far as having them "escape" out of the prompt to enter updated information and yet retain the original value of that field while updating records. Otherwise if they had 12345 with the cursor at 1 and simply hit ENTER, it would plug in 00000, which I wouldn't want.

In other words, I needed a way for them to bring the field up for them to have the option to update its information and then decide NO, and "Pass" through that field without updating anything. Like I said, the ON ESCAPE seems to work for this.
 
You use the UPDATE exactly as per Tom example.
This will cause every field to be populated with it's value on the accept, instead of being presented with either spaces or zeros depending on the PIC.

So by doing

accept xxx update
on exception do function-key processing
not on exception
do validate field-xxx
end-accept


you know that the user either hit an "Function key" excape included, or has hit enter.

Note that some keys CAN still cause an update of the field depending on the configuration file.

This still does not give the information of whether the user has changed the field or not.
If this is important then save the value of the field before doing the accept and compare these two after the accept.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
David,

I gather that you want to get both the data (as seen on the screen) and the termination key (what the user actually typed to cause the ACCEPT statement to return control to your program). You can get both.

To fetch the code for the termination key, merely do the following ACCEPT:
Code:
[u]ACCEPT[/u] [i]identifier[/i] [u]FROM[/u] [u]ESCAPE[/u] KEY
where identifier is a numeric data item capable of storing at least two decimal digits. The codes are listed in Table 6-3 of the RM/COBOL Language Reference Manual. There is a much more expansive treatment of ACCEPT and DISPLAY in the RM/COBOL User's Guide in Chapter 8.

So, you may have your data, and termination too!

(Note to those who might be interested: Coming in RM/COBOL v9, you may specify a data-item to receive the exception code in the manner of one of our [ahem] competitors on a program-wide basis.)

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top