April 27, 1981 You can specify the HECNO option on the FSREAD or FSWRITE macro instruction, or you may change the FSCBITNO or FSCBAITN field in the FSCB for the file, as necessary for the FSCB form. For example, to read the first record and then the 50th record of a file, you could code the following: R EAD1 READ50 RFSCB WFSCB COMMON FSREAD FSCB=RFSCB,FORM=E FSWRITE FSCB=WFSCB,FORM=E LA 5,RFSCB USING FSCBD,5 MVC FSCBAITN,=F'50' FSREAD FSCB=RFSCB,FORM=E FSWRITE FSCB=WFSCB,FORM=E FSCB 'INPUT FILE A1',BUFFER=COMMON,BSIZE=120,FORM=E FSCB 'OUTPUT FILE A1',BUFFER=COMMON,BSIZE=120,FORM=E DS CL120 FSCBD In this example, the statements at the label READ1 write record i from the file INPUT FILE A1 to the file OUTPUT FILE A1. Then, using the DSECT qenerated by the FSCBD macro, the FSCBAITN field is changed because an extended FSCB is being used and record 50 is read from the input file and written into the output file. !!RIAB1E-L]]§,!,H When you read or write variable-length records, you must specify RECFM=V either in the FSCB for the file or on the FSWRITE or FSREAD macro instruction. The read/write buffer should be large enough tc accommodate the largest record you are goinq to read or write. To write variable-length records, use the BSIZE= option on the FSWRITE macro instruction to indicate the record length for each record you write. When you read variable-length records, register 0 contains, on return from FSREAD, the length of the record read. The following example shows how you variable-length file: could read and write a READ FSREAD 'DATA CHECK A1',BUFFER=SHARE,BSIZE=130,ERROR=OUT, FORM=E FSWRITE 'COpy DATA A1',BUFFER=SHARE,BSIZE=(0) ,FOFM=E B READ You can specify the ERROR= operand with the FSREAD or FSWRITE macro instruction, so that an error handling routine receives control in case of an error. In CMS, when an end of file occurs during a read request, it is treated as an error condition. The return code is always 12. If you specify an error handling routine on the FSREAD macro instruction, then the first thing this routine can do is check for a 12 in register 15. Your error handling routine may also check for other types of errors. See the macro description in 111L370 !;MS and for details on the possible errors and the associated return codes. Section 13. Programming for the CMS Environment 247