1 /*
  2 
  3           The procedure cobol_read_gen.pl1 generates code which realizes the COBOL
  4 read statement .
  5 
  6           READ fn [id] eos
  7 
  8                     eos       a=000     neither
  9                                 001     END
 10                                 010     INVALID
 11 
 12                               b=0       no INTO
 13                                 1       INTO
 14 
 15                               c=0       no KEY
 16                                 1       KEY
 17 
 18                               d=00      no NEXT
 19                                 01      NEXT
 20 
 21                               e         key number
 22 
 23                               f=00      no NOT
 24                                 01      NOT
 25 
 26                     verb=21
 27 
 28           mp.n                3-4
 29           mp.ptr(1)           type-1("READ")
 30           mp.ptr(2)           type-12(file-name)
 31           mp.ptr(3)           type-9(INTO id)
 32           mp.ptr(n)           eos
 33 
 34           org=rel   acc=seq   1: read[next][end]
 35                     acc=ran   1: read[invalid]
 36                     acc=dyn   1: read next[end]
 37                               2: read[invalid]
 38 
 39           org=ind   acc=seq   1: read[next]
 40                     acc=ran   2: read[key][invalid]
 41                     acc=dyn   1: read next[end]
 42                               2: read[key][invalid]
 43 
 44 Flow Chart
 45 
 46                               read_next_sw =      file_table.access < 2         seq
 47                                                   |
 48                                                   end_stmt.d = "01"b            read next
 49 
 50                               alt_sw =  file_table.organization = 3   ind
 51                                         &
 52                                         file_table.alternate_keys ^= 0
 53 
 54 
 55 TAG(ioerror.retry_error):
 56 
 57           OP63(init_read,ntag)
 58           GEN_IOERROR
 59 
 60 TAG(ntag):
 61 
 62           if file_table.organization = 4          stream
 63           then      do;       OP64(get_line,ntag);GEN_IOERROR
 64 
 65 TAG(ntag):
 66 
 67                     end;
 68           else      do;       if        file_table.access = 3         dyn
 69                                         &
 70                                         (         file_table.external
 71                                                   |
 72                                                   file_table.open_ext
 73                                         )
 74 
 75                               then      do;       INCR_NTAG
 76                                                   OP54(delete_error,ntag);GEN_ERROR
 77 
 78 TAG(ntag):
 79 
 80                                         end;
 81 
 82                               iosw =    file_table.access < 2         seq
 83                                         &
 84                                         (         file_table.external
 85                                                   |
 86                                                   file_table.delete
 87                                                   |
 88                                                   file_table.write
 89                                         )
 90 
 91                     if        read_next_sw
 92 
 93                     then      do;       if        (         file_organization>1 not-seq
 94                                                             &
 95                                                             iosw
 96                                                             &
 97                                                             file_table.access < 2         seq
 98                                                   )
 99                                                   |
100                                                   (         file_table.organization = 2   rel
101                                                             &
102                                                             file_table.relative_key
103                                                   )
104 
105                                         then      do;       INCR_NTAG
106 
107                                                             OP69(read_key_for_read,ntag);GEN_IOERROR
108 
109 TAG(ntag):
110 
111                                                   end;
112                                         else      do;
113 
114                               if alt_sw
115                               then      do;       INCR_NTAG
116                                                   IO_UTIL$FILE_DESC
117                                                   OP92(alt_find_rec,ntag,skip_read_tag)
118 TAG(ntag):
119                                                   SET_FSBPTR
120                                         end;
121                                                   end;
122 
123                               end
124                     else      do;       if alt_sw
125                                         then      do;       IO_UTIL$FILE_KEY(0,0)
126                                                             IO_UTIL$FILE_DESC
127                                                             IO_UTIL$FILE_NUM
128                                                             OP84(alt_read_key)
129                                                             SET_FSBPTR
130                                                   end;
131 
132                                         INCR_NTAG
133                                         OP67(read_seek_key,ntag);GEN_IOERROR
134 
135 
136 TAG(ntag):
137 
138                               end;
139 
140                               INCR_NTAG
141 
142 
143                               if        read_next_sw
144 
145                               then      do;       OP65(read_record,ntag)
146 
147                                                   if alt_sw then      do;
148 
149 TAG(skip_read_tag):
150 
151                                                                       end;
152                               else      OP66(nonseq_read_tag,ntag)
153 
154 TAG(ntag):
155 
156                               if alt_sw
157                               then      do;       IO_UTIL$FILE_DESC
158                                                   SET_FSBPTR
159 
160                                                   if read_next_sw
161                                                   then      OP80(alt_read_next,0)
162                                                   else      OP81(alt_read_key,0)
163                                         end;
164 
165                     end;
166 
167 */
168 
169 %include cobol_opr_read;
170