问题
I have the following code for processing an indexed file but I am getting a runtime error, "indexed file system not available" when I run the program. I'm not sure on how to code the index file and the data file though. Am I doing the initialization right? What am doing wrong?
IDENTIFICATION DIVISION.
PROGRAM-ID. INDEXFILE.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT VENDOR-FILE ASSIGN TO DISK
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS VENDOR-NUMBER.
DATA DIVISION.
FILE SECTION.
FD VENDOR-FILE
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "input.txt"
DATA RECORD IS VENDOR-RECORD.
01 VENDOR-RECORD.
05 VENDOR-NUMBER PIC 9(5).
05 VENDOR-NAME PIC X(30).
WORKING-STORAGE SECTION.
01 VNAME PIC X.
PROCEDURE DIVISION.
PARA1.
OPEN INPUT VENDOR-FILE.
DISPLAY 'ENTER VENDOR NO: '.
ACCEPT VENDOR-NUMBER.
DISPLAY VENDOR-NUMBER.
READ VENDOR-FILE
INVALID KEY DISPLAY 'NO SUCH RECORD'.
CLOSE VENDOR-FILE.
STOP RUN.
回答1:
DOSBOX emulates an MS-DOS operating system as it would run on an older IBM PC Compatible computer. DOSBOX was developed primarily to support running vintage computer games on newer machines with upgraded operating systems. DOSBOX is not the compiler you are using - it is the operating system. As such we still don't know what "flavour" of COBOL you are trying to use here. All that aside, the message you are getting is: Indexed file system not available and this is hinting that you are missing some of the run time support libraries for the version of COBOL you are using.
Index file systems are not directly supported by the MS-DOS operating system (or any other PC type operating system for that matter). File access, other than simple sequential, requires some type of run-time support and I suspect that you are missing these components in your operating environment. The prospect of getting much further without locating the missing components is low.
回答2:
All we really know is that you are running something which allows old software to run as it did some time in the past (DOSBOX).
We don't know which compiler you have. You should try to find a name by looking for any text output produced when you compile your program, or try "switches" like /? /h /help -? -h -help --help
added to what you have when you compile a program.
Do you have any documentation for the compiler? Once you find out which compiler it is, you may be able to find some with your favourite search-engine.
To create your first indexed file, write a small program which opens an indexed file for OUTPUT
. WRITE
the records that you want, then CLOSE
the file and stop the program.
That will usually be enough to get an indexed file going. You should then be able to use that file as INPUT
or I-O
in another program.
It is always a good idea to use FILE STATUS. If you are not sure how to use this, and still don't have a manual, look at the GNU COBOL documentation at SourceForge.
来源:https://stackoverflow.com/questions/21970061/indexed-file-processing-in-cobol-error