Visual Cobol: File Access


I am using Managed Visual Cobol for Microsoft Visual Studio. I access files using the COBOL Open, Read, Write, Rewrite and Close. I have two Forms. form1 produces FORM2. Form2 has one textbox, several labels, some of witch receive data from the program, and three buttons.

My Problem is this:

Everything was going great. Reading data. Displaying data etc. I had a problem and stopped the Debugger and corrected the problem. Ever since then, the index read has returned an empty record. The only data in the record is the key witch was moved in by the program. I also tried a process that read the same file sequentially. Same results, an empty record. I have tried recycling the computer and full power down. same Results. I even deleted the physical files and tried to recreate it with another program. The File is NOT recreated. This Program has not changed. It opens for output, reads the data from a text file and then writes to the index file. I have checked all input and output fields and everything looks correct. The physical file isn't even created. I have checked the path and this is correct.

What is causing this and what can I do!?

On a different subject with the same form. I have associated an event handler to the "Exit" button. Twice I have found that this handler is no longer associated with the button. Also the button has lost its "click" method. The code is still there. When I double click on the button it creates a new method wit a "_1" appended.

Any Ideas?

  • Verified Answer

    Which product version are you using?

    Look under Visual Studio Help-->About Microsoft Visual Studio and then click on Micro Focus Visual COBOL in the list and you will see the version number.

    For the first problem with the File Handler it sounds as if some type of error is occurring on the file open.
    Are you checking the file status code after each I-O operation?
    Can you please tell me what the file status is after the open of the file?

    When you state that you had a problem and you corrected it, what was the problem that you had and what did you do to correct it?

    For the event handling problem,it sounds like your source file and the designer.cbl file are perhaps out of sync. When you refer to the event handler code no longer being associated to the button do you see the event handler defined in the designer.cbl file.

    It would look something like:

    invoke button1::add_Click(new System.EventHandler(self::button1_Click))


  • Hi Chris

        Thanks for your response. I don't Know what caused the initial problem, but once I was able to recreat the file, the problem went away. This is referring to the index read. The sequential read was a different problem. Your response pointed me in the right direction. I split the open statement into two open statements and put a watch on my extended file status. What I got was 9/004 "Invalid file Name". It turns out that when I return from using Form2 The fields I used to hold the path and name of the file were trashed. I have an event handler for the return from Form2. I put the code to recreate this information in that event handler and now everything is working smoothly. I am used to working with RM/COBOL and things like this just don't happen.

        As for the "Exit" button problem. The example you show was found in the designer.cbl file. But of course I had already recreated the button_click event by then. The problem hasn't happened lately. I'll check the designer file if it does.

        The Information For my release is as follows:

    Microsoft Visual Studio 2010

    Version 10.0.40219.1 SP1Rel

    Microsoft .NET Framework

    Version 4.0.30319 SP1Rel

    Installed Version: IDE Standard

    Microsoft Visual Web Developer 2010   01011-532-2002361-70695

    Microsoft Visual Web Developer 2010

    Hotfix for Visual Studio 2010 Shell (Integrated) - ENU (KB2548139)   KB2548139

    Hotfix for Visual Studio 2010 Shell (Integrated) - ENU (KB2549864)   KB2549864

    Hotfix for Visual Studio 2010 Shell (Integrated) - ENU (KB2635973)   KB2635973

    Micro Focus Visual COBOL 2.1   Serial number: 600000519761

    Micro Focus Visual COBOL 2.1 Version 2.1.01045.

    Serial number: 600000519761 Personal license

    Security Update for Visual Studio 2010 Shell (Integrated) - ENU (KB2645410)   KB2645410

    Visual Studio 2010 Shell (Integrated) - ENU Service Pack 1 (KB983509)   KB983509

        Again thank you very much for your assistance.