ACCEPT verb behavior

Hi everybody,

I am new at COBOL and learning from a book. I have a problem with the verb ACCEPT.

Here is the code I have written

WORKING-STORAGE SECTION.

   01 UserName PIC X(20).
  *-----------------------
   PROCEDURE DIVISION.
  *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
   Begin.
       DISPLAY "Please enter your name - " WITH NO ADVANCING
       ACCEPT UserName
       DISPLAY "************************************"
       DISPLAY "Name is: " UserName
       STOP RUN.

Compilation is done smoothly but when I run it the prompt waits for me to enter the UserName but Please enter your name- does not appear.

Any suggestion is welcome.

thank you

1 Like

Hello pifou, it happened to me, I don’t know if it was a compiler error, you just have to remove WiTH NO ADVANCING and it would work fine for you

It’s been a long time; so, I first imagined that there might be a problem with the coding. I wanted to suggest putting a “period” (“.”) at the end of each statement. But, that wouldn’t have made sense; because, you said that the program compiled, and that you got to the “ACCEPT” statement, without he program crashing.

So, now, I’m imagining that you’re using an “OUTDD(ddname)” option, on the instruction that you give to the computer, when compiling.

Here is the content of a description of the explanation, from IBM, on the effects of using the “OUTDD(ddname)” option, when compiling the code:

“Use this option to override the default ddname (SYSOUT) for SYSOUT output that goes to the system logic output unit. If the ddname is the same as the Language Environment® MSGFILE ddname, the output is routed to the ddname designated for MSGFILE. If the ddname is not the same as the Language Environment MSGFILE ddname, the output from the DISPLAY statement is directed to the OUTDD ddname destination. If the ddname is not present at first reference, dynamic allocation will take place with the default name and attributes that are specified by Language Environment.”

“COMPILER OPTIONS FOR CONVERTED PROGRAMS” page

URL: IBM Documentation