Search code examples
cobolgnucobol

Data entered not stored correctly


I have a problem with the Compiler for the programming language COBOL. I use the program "OpenCobolIDE" (GnuCOBOL 1.1 Mingw).

Firstly here is the code of an example program.

   IDENTIFICATION DIVISION.
   PROGRAM-ID. HelloWorld.
   DATA DIVISION.
   FILE SECTION.
   WORKING-STORAGE SECTION.
   01  name           pic x(32).
   PROCEDURE DIVISION.
   beginn section.
        DISPLAY "What is your Name?: " with no advancing.
        accept name.
        DISPLAY "Your Name: ",name .
        STOP RUN.
   END PROGRAM HelloWorld.

After typing my name, "Albert", the console doesn't send the message "Your Name: Albert" back. The Console is after "Albert" empty. But if I set the length of the string name to 6, because my name is 6 characters long, then the program works correctly and the console shows "Your Name: Albert".

In addition to this ,the clause with no advancing doesn't work correctly. When I use this command the console doesn't print "What is your Name?", it skips the line and I have to enter my name first and after entering my name the console shows: "What is your Name?: Albert". But in the .exe of the compiled program the command line with no advancing works correctly.

Why is it so, and how I can repair that?


Solution

  • It looks like you use the embedded python console OCIDE uses for better integration. The side effect is: it is not fully functional, as soon as you start to use anything other than very simple ACCEPT/DISPLAY you should disable it:

    Preferences (F2) -> Tab Run -> check "Run in external terminal"

    BTW: The windows installation of OpenCOBOL IDE ships with the latest official MinGW package of GnuCOBOL. This currently is 1.1 but very soon will be GnuCOBOL 2.0 rc2 (or final), I highly suggest to use this one instead of the older GnuCOBOL 1.1. You can get an unofficial preview version with the rc1 and/or stay tuned for the new version (which will likely be added to OCIDE, too).

    Edit: As found in the comment:

    The Problem was the old version of GnuCOBOL 1.1, because after updating it works correctly!