	title	Module from library HILIB_3 : @OPENI
	name	('@OPENI')
	maclib	baselib.lib

; Language : BASIC

; Open existing file

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

;		Version 1.0, August 1987

; ENTRY	Reg pair HL points to string describing file
;	Reg pair DE points to FCB or channel parameter block
;	Reg C holds channel in range 1 up to 15 on channel
;	transfer or 0 on simple FCB set up

; EXIT	Carry set on error and accu holds error code
;	- 52 file number error
;	- 53 file not found
;	- 55 file already open
;	- 64 file name invalid

	entry	@openi

	extrn	open,chnini,@ftcfl,@tstch

@openi:
	push	de
	call	@ftcfl		; Get file
	pop	de
	ret	c		; Aha, error
	ld	a,c		; Test kinda transfer
	or	a
	jr	nz,opnch	; Go open channel
	call	open		; Test file here
	ret	nc
	ld	a,53		; Set error
	ret
opnch:
	call	@tstch		; Test channel ok
	ret	c
	ld	b,0
	call	chnini		; Init channel
	ret	nc
	ld	a,53		; Set error
	ret

	end

