Processing Files and Records
6.4 Reading Files
Example 6–35 (Cont.) Reading an Indexed File Dynamically, with READ PRIOR
*+
* READ PREVIOUS after file open for IO, from a middle
* record to beginning record on primary key.
*+
OPEN I-O F.
MOVE "2345678990" TO R.
READ F INVALID KEY DISPLAY "?6" GO TO P2 END-READ.
IF R NOT = "2345678990" THEN DISPLAY "?7 " R.
READ F PREVIOUS AT END DISPLAY "?8" GO TO P2 END-READ.
IF R NOT = "1234567890" THEN DISPLAY "?9 " R.
READ F PREVIOUS AT END DISPLAY "?10" GO TO P2 END-READ.
IF R NOT = "0123456789" THEN DISPLAY "?11 " R.
READ F PREVIOUS AT END GO TO P2.
DISPLAY "?12 " R.
*+
* Multiple READ PREVIOUS on a display alternate key with
* duplicates.
*+
P2. MOVE "91" TO K2.
READ F KEY K2 INVALID KEY DISPLAY "?13" GO TO P5 END-READ.
R NOT = "9876543291" THEN DISPLAY "?14 " R.
READ F PREVIOUS AT END DISPLAY "?15" GO TO P5 END-READ.
IF R NOT = "2345678990" THEN DISPLAY "?16 " R.
READ F PREVIOUS AT END DISPLAY "?17" GO TO P5 END-READ.
IF R NOT = "1234567890" THEN DISPLAY "?18 " R.
READ F PREVIOUS AT END DISPLAY "?19" GO TO P5 END-READ.
IF R NOT = "0123456789" THEN DISPLAY "?20 " R.
READ F PREVIOUS AT END GO TO P5.
DISPLAY "?21 " R.
P5. CLOSE F.
DISPLAY "***END***".
STOP RUN.
Reading an Indexed File from Other Languages on Tru64 UNIX
COBOL supports more data types for indexed keys than are supported in the
ISAM definition. For keys in any of the data types not supported in the ISAM
definition, the run-time system will translate those keys to strings. Table 6–7
specifies the appropriate mapping to create or use indexed files outside of COBOL
(For example, if you are using the C language on Tru64 UNIX and you need to
access COBOL files). See the ISAM package documentation for details of the file
format.
Table 6–7 Indexed File—ISAM Mapping
COBOL Data Type
Maps To
Transformation Method
character string
PIC x(n)
CHARTYPE
None.
short signed int
PIC S9(4) COMP
INTTYPE
C-ISAM
long signed int
PIC S9(9) COMP
LONGTYPE
C-ISAM
(continued on next page)
Processing Files and Records 6–47
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......