;*************************** AMUS Program Label ******************************
; Filename: WRTREC.SBR                                      Date: 06/12/89
; Category: DISK         Hash Code: 653-521-226-042      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: Write to a sequential file from any size/type variable with
;       control over the number of bytes to be written.
;
;*****************************************************************************
;* Updated on 12-Jun-89 at 9:03 PM by ; edit time: 0:03:47 *;
; WRTREC Write record to a sequetial file from a buffer
;
; Syntax:
;       XCALL   WRTREC,FILE,BUFFER{,COUNT}
;
;
; (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
;
       SYM
       MAYCREF
       OBJNAM  .SBR
       SEARCH  SYS
       SEARCH  SYSSYM
       RADIX   16.
       DEFAULT VEDIT,1
       DEFAULT $$MFLG,PV$RSM
       DEFAULT $$SFLG,PH$REE!PH$REU
       PHDR    -1,$$MFLG,$$SFLG

       EXTERN  $FLSET

       DEFINE  BTYPE N,DEST
1$$     =       2+^D10*<N-1>
       CLR     DEST
       MOVW    1$$(A3),DEST
       ENDM

       DEFINE  BADRS N,DEST
1$$     =       4+^D10*<N-1>
       MOVL    1$$(A3),DEST
       ENDM

       DEFINE  BSIZE N,DEST
1$$     =       8+^D10*<N-1>
       MOVL    1$$(A3),DEST
       ENDM
;
;-------
;
WRTREC:
       CMPW    @A3,#3
       BEQ     10$
       CMPB    @A3,#2
       BEQ     10$
       TYPECR  <?Wrong numbber of parameters given to XCALL WRTREC>
       EXIT
10$:
       BADRS   1,A6
       FFTOL   @A6,D1
       CALL    $FLSET
       BEQ     15$
       TYPECR  <?Bad file channel given to XCALL WRTREC>
       EXIT
15$:
       MOV     A2,A4                   ; A4->DDB

       BADRS   2,A5                    ; A5->DATA
       BSIZE   2,D5                    ; D5=SIZE(DATA)

       CMPW    @A3,#3                  ; optional 3rd paramters present?
       BLO     18$                     ; no
       BADRS   3,A6                    ; get COUNT paramter
       FFTOL   @A6,D5                  ; redefine SIZE(DATA)
18$:
       DEC     D5                      ; for DBxx
20$:
       MOVB    (A5)+,D1                ; get next data byte
       FILOTB  @A4                     ; output to file
       DBF     D5,20$                  ; loop until done
       RTN
;
;
       END