Programs hangs when opening COBOL Indexed file

2019-08-21 02:40发布

I've recently started a COBOL course and, because of my computer configuration (Windows 7 64 Bits and GNU/Linux 64Bits) I have to use Dosbox to compile and execute programs.

Everything is going well but, I'n finding some troubles when I try to open an Indexed file, either I-O or Ouput mode. I can compile and link but at execution time, dosbox get frozen.

My compiler version is MS-COBOL 5.0 and DosBox is 0.74 (last version).

Does anybody have had this issue? Can someone tell how to fix it.

My code is this one.

Thanks in advance.

   IDENTIFICATION DIVISION.

   PROGRAM-ID. AGENDA.
   AUTHOR. JOSE MARIA RAMIREZ MIRA.
   DATE-WRITTEN. 06/05/2014.
   DATE-COMPILED. 06/05/2014.

   ENVIRONMENT DIVISION.

   CONFIGURATION SECTION.

   SOURCE-COMPUTER. IBM-PC.
   OBJECT-COMPUTER. IBM-PC.

   SPECIAL-NAMES.
       DECIMAL-POINT IS COMMA.

   INPUT-OUTPUT SECTION.
   FILE-CONTROL.

       SELECT AGENDA ASSIGN TO DISK "AGENDA.DAT"
              ORGANIZATION IS INDEXED
              ACCESS IS RANDOM
              RECORD KEY IS AG-NICK
              FILE STATUS IS AG-STATUS.

   DATA DIVISION.

   FILE SECTION.
   FD AGENDA
      RECORD CONTAINS 112 CHARACTERS
      LABEL RECORD IS STANDARD
      DATA RECORD IS AG-PERSONA.

   01 AG-PERSONA.
      03 AG-NICK                PIC X(25).
      03 AG-NOMBRE              PIC X(25).
      03 AG-APELLIDOS           PIC X(50).
      03 AG-TELEFONO            PIC X(12).

   WORKING-STORAGE SECTION.

   77 AG-STATUS                 PIC 99.
      88 EXITO                  VALUE 00.
      88 CLAVE-DUPLICADA        VALUE 22.
      88 CLAVE-NO-ENCONTRADA    VALUE 23.
      88 SIN-ESPACIO-EN-DISCO   VALUE 34.
      88 FICHERO-NO-EXISTE      VALUE 35.
      88 EOF                    VALUE 10.

   PROCEDURE DIVISION.
   MAIN-PROCEDURE.

       DISPLAY "PROCEDO A ABRIR EL ARCHIVO".
       OPEN I-O AGENDA.
       IF EXITO THEN
          DISPLAY "EL ARCHIVO SE HA ABIERTO"
       ELSE
          EVALUATE TRUE
             WHEN FICHERO-NO-EXISTE
                DISPLAY "EL ARCHIVO NO EXISTE"
          END-EVALUATE
       END-IF.
       CLOSE AGENDA.
       STOP RUN.

   END PROGRAM AGENDA.

3条回答
欢心
2楼-- · 2019-08-21 02:52

What is the absolute path to AGENDA.DAT?

Sometimes with legacy DOS programs you can't read/write files inside folders with spaces on its name. Say, if your current folder is C:\ms cobol\ , rename it to C:\mscobol\.

It's worth a try, if this is your case.

查看更多
神经病院院长
3楼-- · 2019-08-21 03:04

DOSBox was designed for gaming. The problem could be DOSBox missing file and record locking. DOSBox has more issues like internal file caching, a time bomb with multi-user enabled programs. You could try vDos: http://sourceforge.net/projects/vdos/. It is Windows only, but integrates better with it.

查看更多
放我归山
4楼-- · 2019-08-21 03:05

Have you tried selecting the file using the OPTIONAL phrase. For example,

SELECT OPTIONAL AGENDA ASSIGN TO DISK "AGENDA.DAT"
              ORGANIZATION IS INDEXED
              ACCESS IS RANDOM
              RECORD KEY IS AG-NICK
              FILE STATUS IS AG-STATUS.

The OPTIONAL phrase must be specified for files opened for INPUT, I-O, or EXTEND that need not be present when the program runs.

Against this being the problem is your statement that the problem also occurs with OPEN OUTPUT and the program should in any case be producing some output but as others have remarked the version of COBOL is not well known.

By the way I plugged your program into the online COBOL at http://www.compileonline.com/compile_cobol_online.php and it worked fine triggering the FICHERO-NO-EXISTE condition name.

But this does raise another point. In my Microfocus manual the file status code of 35 is given as being returned when an OPEN INPUT, I-O or EXTEND is attempted on a NON-OPTIONAL file that does not exist. A file status of 05 is returned if you have used the OPTIONAL phrase and the file does not exist at the time the OPEN is executed.

查看更多
登录 后发表回答