	.TITLE	AZ_IO

;;
;	Routines AZ_OPEN, AZ_READ, and AZ_CLOSE
;
;
;	These  are simple, no-frill routines to read a card-image file us-
;	ing RMS.
;
;		status = AZ_OPEN('file_name')
;
;		status = AZ_READ()
;
;		CALL AZ_CLOSE
;
;	Only one file may be open at at time using these routines.
;
;	Each call to AZ_READ reads one record (80 characters max) into the
;	string RECORD, defined as:
;
;		CHARACTER*80 RECORD
;		COMMON /READ_/ RECORD
;
;	If the record is longer than 80 characters, it is truncated  with-
;	out notification; if it is shorter than 80 characters, the remain-
;	der  of RECORD has unpredictable contents.   When  end-of-file  is
;	encountered,  the file is closed and a status value of zero is re-
;	turned.
;
;	.INDEX DISK I/O>>
;
;	Alan L. Zirkle     Naval Surface Weapons Center
;			   Code K53
;	15 Jan 1983	   Dahlgren, Virginia  22448
;

	.PSECT	$LOCAL, LONG,PIC,NOSHR,NOEXE,RD,WRT


INFAB:	$FAB	FAC=GET,FOP=SQO

INRAB:	$RAB	FAB=INFAB,ROP=RAH,UBF=RECORD,USZ=80


	.PSECT	$CODE, LONG,PIC,SHR,EXE,RD,NOWRT


	.ENTRY	AZ_OPEN, ^M<>

	MOVL	@4(AP), R0

	MOVB	R0, INFAB+FAB$B_FNS

	MOVL	4(AP), R0

	MOVL	4(R0), INFAB+FAB$L_FNA

	$OPEN	FAB=INFAB

	BLBC	R0, EXIT

	$CONNECT RAB=INRAB

EXIT:	RET

	.ENTRY	AZ_READ, ^M<>

	$GET	RAB=INRAB

	BLBS	R0, RETURN

	CMPL	R0, #RMS$_RTB

	BNEQ	QUIT		; QUIT UNLESS 'RECORD TOO LARGE'

	INCL	R0

RETURN:	RET

	.ENTRY	AZ_CLOSE, ^M<>

QUIT:	$CLOSE	FAB=INFAB

	CLRL	R0

	RET	


	.PSECT	READ_,PIC,OVR,GBL,SHR,NOEXE,LONG


RECORD:	.BLKB	80

	.END
