April 27, 1981
248.2 IBM VM/370 eMS User's Guide
Page of GC20-1819-2 As Updated April 27, 1981 by TNL SN25-0828 For 5748-XE1 LINE SOURCE STATEMENT BEGIN CSECT 1 PFINT NOGEN USING *,12 ESTABLISH ADDRESSABILITY LF 12,15 ST 14,SAVE LA 2,8{,1) R2=ADDR OF INPUT FILEID IN PLIST 2
LA 3,32{,1) R3=ADDR OF OUTPUT FILEID IN PLIST * DETERMINE IF INPUT FILE EXISTS FSSTATE (2) ,ERROR=EFR1,FORM=E *
* READ A RECORD FROM INPUT FILE AND WRITE ON OUTPUT FILE
RD FSREAD (2),ERROR=EOF,BUFFER=BUFF1,BSIZE=80,FORM=E 3 FSWRITE {3} ,ERROR=ERR2, BUFFER=BUFF1, BSIZE=80,FORM=E B RD LOOP BACK FOR NEXT RECORD
*
* COME HERE IF ERROR READING INPUT FILE EOF C 15,=F'12' END OF FILE ? BNE ERF3 ERROR IF NOT LA 15,0 ALL O.K. - ZERO OUT R15
B EXIT GO EXIT * IF INPUT FILE DOES NOT EXIST ERR1 WFTERM 'FILE NOT FOUND',EDIT=YES B
*
* IF ERROR WRITING FILE t
ERR2 LR 10,15 SAVE RET CODE IN REG 10 5 I LINEDIT TEXT='ERROR CODE •••• IN WRITING FILE',SUB=(DEC,(10» I B EXIT *
* IF READING ERROR WAS NOT NORMAL END OF FILE
ERR3 LR 10,15 SAVE RET CODE IN REG
LINEDIT TEXT='EFROR CODE •••• IN READING
* EXIT * BUFF1 SAVE I L
BF DS DS END 14,SAVE 14 CL80 F LOAD RETURN ADDRESS RETURN TO CALLER , 10 5 I FILE',SUB=(DEC,(10» , I I I I I t I 1 The program miqht be invoked with a parameter list in the format I progname INPUT FILE A1 OUTPUT FILE A1. This line is placed in a I parameter list by CMS routines and addressed by register 1 I (see note 2). I 2 The parameter list is a series of doublewords, each containing lone of the words entered on the command line. Thus, 8 bytes I past register 1 is the beginning of the input fileid; 24 bytes I beyond that is the beginning of the second fileid. I 3 The FSREAD and FSWRITE macros cause the files to be opened; no I open macro is necessary. Except for programs running under the I control of EXEC, eMS routines close all open files when a program
t completes execution. I The return code in register 15 is tested for the value 12, I which indicates an end--of-file condition. If it is the end of I the file, the program exits; otherwise, it writes an error I messaqe. I 5 The dots in the LINEDIT macro are SUbstituted, during execution, I with the decimal value in register 10. L
Fiqure 21. A Sample Listing of a Program that Uses CMS Macros Section 13. Programming for the CMS Environment 249
Previous Page Next Page