	title	Module from library BASE_5 : RDRNDR
	name	('RDRNDR')
	maclib	baselib.lib

; Read a record with variable length

; Copyright (C)	Werner Cirsovius
;		Hohe Weide 44
;		D-20253 Hamburg
;		Tel.: +49-40-4223247

;		Version 1.0 April 1987

; ENTRY	Accu 	    holds record length (1 .. 255)
;	Reg pair BC holds record number (1 .. n)
;	Reg pair DE holds FCB of opened file
;	Reg pair HL holds pointer of text to be read

; EXIT	Carry set on error, either disk or parameter error
;	Carry reset on successfull operation

	entry	rdrndr

	extrn	@tsrec,@gtphs,@gtrec,@mvrec,@fxnxt

rdrndr:
	call	@tsrec		; Test valid record number
	ret	c		; Exit on parameter error
	call	@gtphs		; Get 'physical' sector
rdlop:
	push	de
	call	@gtrec		; Get a random record
	jr	c,rderr		; Exit on error
	call	@mvrec		; Move record to buffer
	jr	z,endred	; Ok, that's it
	call	@fxnxt		; Else fix for another record
	pop	de
	jr	rdlop
endred:
	or	a		; Reset error
rderr:
	pop	de
	ret

	end

