Chubonga93
Chubonga93

Reputation: 9

What is the specific function of PROMPT and ECHO alongside an ACCEPT statement in COBOL

I was looking through some source code for a RM/COBOL program and I keep running into ACCEPT statements similar to this:

   ACCEPT field-name LINE 23, POSITION 75 PROMPT ECHO

There are similar ACCEPT statements like this one that functions as input fields but have no PROMPT ECHO alongside them.

So my question is: What is the functionality of the PROMPT ECHO?

Thanks, Chubonga93

Upvotes: 1

Views: 1283

Answers (2)

Molusco
Molusco

Reputation: 69

I can help, i use ECHO everyday, is simple as this: Whenever the ACCEPT statement is run, it shows the current value of the identifier.

Say, you have this picture:

01 WS_NAME PIC X(20) VALUE "Chubonga".

And this ACCEPT:

DISPLAY "Enter name:".
ACCEPT WS_NAME ECHO.

The program will prompt:

Enter name:
Chubonga

If you change the value of WS_NAME at execution time and the ACCEPT is rerun, it will show the new value of said identifier.


Edit: Depending on the compiler, it may or may not echo back the value if it was set by VALUE instead of MOVE or previous ACCCEPT.

Upvotes: 2

David Gorsline
David Gorsline

Reputation: 5018

From Micro Focus's documentation (of their support for RM/COBOL's) PROMPT clause:

The PROMPT clause causes the empty character positions in the screen item to be marked on the screen during an ACCEPT operation while the system is ready to accept operator-keyed data into that item.

The general format is

PROMPT [CHARACTER IS { identifier-1, literal-1 } ]

which doesn't account for your ECHO keyword. But this compatibility guide entry alludes to the ECHO keyword:

5.2.14 Display of Input Data in Concealed ACCEPT Fields

If you have specified OFF and ECHO clauses for the same ACCEPT statement in your program, the RM/COBOL system will conceal any data entered during input for that statement but on completion of input will display the data. This COBOL system, however, will not display the data for this ACCEPT statement once input has been completed. Solution:

If you wish to display the data input for an ACCEPT statement with the OFF and ECHO clauses specified, you must add a DISPLAY statement after the ACCEPT statement.

I see several references online that document NO ECHO (which has the effect that the user's input is not displayed to the screen) but nothing firm for ECHO. I suspect that it has no effect in your case, that is, that the user's input is echoed as usual.

Upvotes: 1

Related Questions