;*************************** AMUS Program Label ******************************
; Filename: REDREC.SBR Date: 06/12/89
; Category: DISK Hash Code: 504-343-065-500 Version: 1.0(1)
; Initials: AMI Name: AMI BAR-YADIN
; Company: UNITED FASHIONS OF TEXAS Telephone #: 5126312277
; Related Files: (there is also a WRTREC.SBR)
; Min. Op. Sys.: NA Expertise Level: BEG
; Special:
; Description: Read from a sequential file into any size/type variable with
; control over number of bytes to be read
;
;*****************************************************************************
;* Updated on 12-Jun-89 at 9:02 PM by ; edit time: 0:04:26 *;
; REDREC Read record from a sequential file into a buffer
;
; Syntax:
; XCALL REDREC,FILE,BUFFER{,COUNT}
;
; FILE ,F File channel number of open seq file
; BUFFER ,X,? Buffer, any type, any size
; COUNT ,F Count of bytes requested/actually read
;
;
; (C)1988,89 By Ami Bar-Yadin.
; AMUS ID: AMI/AM
;
;-All commercial rights reserved, etc.
;-No warranties and/or guarranties of any kind, etc.
;-Not responsible for damages resulting from the use of this program, etc.
;-My employer (United Fashions) has nothing to do with this program and
; should not be blamed for it.
;
; I can be reached at:
; United Fashions of Texas, Inc.
; 200 Ash Ave.
; McAllen, TX 78501
; (512) 631-2277
; 8am-6pm
;
;
; REDREC will read bytes from a file into a buffer.
; o BUFFER may be any size, any type of variable.
; o If EOF is reached before BUFFER is full, it is padded with NULLs.
; o If COUNT is not specified, BUFFER is filled up.
; o If COUNT is specified:
; o Only COUNT bytes will be read in to BUFFER,
; unless COUNT is zero, in which case the BUFFER is filled up.
; o The number of bytes actually read will be returned
;
;
CMPW @A3,#3 ; optional 3rd paramters present?
BLO 18$ ; no
BADRS 3,A6 ;
FFTOL @A6,D1 ; get COUNT paramter
TST D1
BEQ 18$ ; ignore if zero
CMP D1,D5 ; check against buffer size
BHI 81$ ; too big
MOV D1,D3 ; set COUNT
18$:
DEC D3 ; for DBxx
CLR D2 ; Clear actual count
20$:
FILINB @A4 ; input from file
TST D.SIZ(A4)
BEQ 23$ ; END OF FILE
MOVB D1,(A5)+ ; store in buffer
DEC D5 ; Count space left in buffer
INC D2 ; Count characters placed in buffer
DBF D3,20$ ; loop until done
DEC D5
BMI 30$ ; Continue if BUFFER is full
23$: CLRB (A5)+ ; Pad with NULLs
DBF D5,23$ ; to buffer's end
;
; return actual count to parameter 3 if present
30$:
CMPW @A3,#3 ; optional 3rd paramters present?
BLO 39$ ; no
BADRS 3,A6 ; Address of COUNT parameter
FLTOF D2,@A6 ; Return acutal COUNT
39$: RTN
; Error routines
;
80$:
TYPE <?#parameters BAD>
BR 89$
81$:
TYPE <?#bytes requested GT buffer size>
; BR 89$
; finalize error message and exit
89$:
TYPECR < in XCALL REDREC>
EXIT
;
END