Microsoft KB Archive/44764

From BetaArchive Wiki


PSS ID Number: Q44764 Article last modified on 04-20-1993

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

The information in this article applies to:
- Microsoft COBOL for MS-DOS and OS/2, versions 3.0 and 3.0a

Summary: There are three ACCESS MODEs for COBOL INDEXED and RELATIVE files: DYNAMIC, RANDOM, and SEQUENTIAL. The ACCESS MODE is set in the ENVIRONMENT DIVISION SELECT clause with the ACCESS MODE statement. The ACCESS MODE for an INDEXED or RELATIVE file determines which verbs are legal to use for that file. Also, the MODE you choose determines which order you can use to ACCESS records in the file. There is one important difference between RELATIVE and INDEXED files when using the three access modes. RELATIVE files are ordered by their physical position on the disk. INDEXED records are not ordered by their physical position, but by the collating sequence of the RECORD KEY item in the record description. All INDEXED file access, whether RANDOM or SEQUENTIAL, is based on the current value in the RECORD KEY.

More Information: The following is a brief summary of the order which can be used in each MODE: 1. ACCESS MODE SEQUENTIAL You can only ACCESS the file SEQUENTIALly from the beginning to the end. For RELATIVE files, this means any file ACCESS starts with the first physical record and ends when the last physical record is reached. For INDEXED files, this means that the READ “starts” with the lowest RECORD KEY value and “ends” when the highest one is reached. For an INDEXED file WRITE there is an added restriction. Each time a record is written, the KEY in the RECORD KEY must be strictly greater than the one last written. 2. ACCESS MODE RANDOM You can only ACCESS the file RANDOMly. When you want to move from one record to another, you must first move the desired KEY into the RECORD KEY or RELATIVE KEY item, and then READ. 3. ACCESS MODE DYNAMIC You can ACCESS the file SEQUENTIALLY backward or forward, or read it RANDOMly. These two modes can be mixed at will. The available MODEs and how each of the file-handling verbs behaves in that MODE is summarized in the following table: || ACCESS MODE | ACCESS MODE | ACCESS MODE | || SEQUENTIAL | RANDOM | DYNAMIC | ________||__________________|__________________|__________________| ——–||——————|——————|——————| || Reads the file | Reads the record | Reads the record | READ || just like a | specified in the | specified in the | || sequential file. | RECORD KEY or | RECORD KEY or | || Order is based on| RELATIVE KEY. The| RELATIVE KEY. The| || the RECORD KEY | file pointer is | file pointer is | || or RELATIVE KEY. | not moved to the | not moved to the | || | next record. | next record. | ________||__________________|__________________|__________________| || Writes the record| Writes the record| Writes the record| || currently in the | currently in the | currently in the | || FD record. For | FD record. | FD record. | || INDEXED files the| RECORDs can be | RECORDs can be | WRITE || RECORD KEY must | written in any | written in any | || be greater than | order. | order. | || the last RECORD | | | || KEY written. | | | ________||__________________|__________________|__________________| || Performs the | Not allowed with | READs the NEXT | || same as READ in | this MODE. | record. Allows | READ || this MODE. Reads | | READing the file | NEXT || the file | | SEQUENTIALly in | || sequentially. | | this MODE. | ________||__________________|__________________|__________________| || Not allowed with | Not allowed with | Read the previous| READ || this MODE. | this MODE. | record. Allows | PREVIOUS|| | | reading the file | || | | sequentially in | || | | reverse order. | ________||__________________|__________________|__________________| || Not allowed with | STARTS the next | STARTS the next | START || this MODE. | ACCESS of the | ACCESS of the | || | file at a new | file at a new | || | position. | position. | ________||__________________|__________________|__________________|

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.