.TITLE RPTFIO ... report file I/O module .IDENT /010283/ .ENABL LC ; ; ; ; ; Written by Ray Di Marco ; 1-Feb-83. ; ; ;_____________________________________________________________________________ ; ; ; This module is used by DBSMNG CUSPs for performing I/O to report files. The ; module entries are ; ; RPTINT initializes output stream. The report file is oppenned ; for output (create new file mode) and all parameters are ; initialized. The name of the file is stored as a .ASCIZ ; string in the RPTNME buffer; the file name may be changed ; prior to call RPTINT to suit. The default name is ; ; LST:REPORT.LST ; ; RPTEND closes out the output stream. Must be called prior to ; exitting the program to ensure that buffers are emptied ; out and the file closed out properly. ; ; RPTOUC outputs character in R0 to the output stream. A special ; flag RPTFLG is available; if this flag is set then ; output is suppressed. ; ; The user may access the following variables ; ; RPTNME the name of the report file may be loaded into this buffer ; in .ASCIZ format prior to calling RPTINT. ; ; RPTFLG the RPTOUC routine discards any output when the flag is set. ; .SBTTL Modifications ; ; 1-Feb-83 change RPTINT to allow re-initialization of report ; file. ; .SBTTL Declarations ; ; .MCALL .PUSH,.POP ; stacking .MCALL .PRINT,.EXIT ; error handling .MCALL FILSPT ; file support ; FILSPT ; invoke file support ; ; .GLOBL RPTINT,RPTOUC,RPTEND ; entry points .GLOBL RPTNME,RPTFLG ; important data structures ; ; .MACRO FATAL MES,?A,?B .PRINT #'B STATUS .EXIT B': .ASCIZ /'MES'/<15><12><'I-'@><200> .EVEN .ENDM FATAL ; ; .PSECT CODE ; OPEN CODE AREA ; ------ ---- ; .SBTTL Routine - "RPTINT" ... initialization routine ; ; ; Enter file and reset variables needed in output loop. ; RPTINT: PURGE #RPTFDB ; ensure channel free BIS #F.NERR,FDB.FL(R5) ; disable error messages NAME STRING=#RPTNME,EXTENS=#^RLST,ERROR=1000$ ENTER ERROR=1000$ ; Enter File CLR FDB.BL(R5) ; Start output @ block 0 MOV #400,FDB.RQ(R5) ; reset I/O size CLR RPTFLG ; re-enable output MOV #RPTBUF,RPTPNT ; reset store pointer RETURN ; ALL DONE ; 1000$: FATAL ; ; .SBTTL Routine - "RPTEND" .... Close out report file ; ; Append a terminating null to the file and write out last buffer ; before closing out the file. ; RPTEND: CLR R0 ; R0 = NULL CALL RPTOUC ; output a NULL .PUSH R5 ; save MOV RPTPNT,R1 ; R1 -> next position in buffer SUB #RPTBUF,R1 ; R1 = number bytes in buffer BEQ 100$ ; empty -> skip ASR R1 ; R1 = number words in buffer WRITE #RPTFDB,SIZE=R1,ERROR=1000$ 100$: CLOSE #RPTFDB ; close out file .POP R5 ; retore R5 RETURN ; all done ; 1000$: FATAL ; ; .SBTTL Routine - "RPTOUC" ... output a character ; ; This routine outputs the character passed over in R0 to the ; report file. ; RPTOUC: BIT #1,RPTFLG ; output suppressed? BNE 500$ ; yes -> 500$ MOVB R0,@RPTPNT ; save character INC RPTPNT ; bump up pointer CMP RPTPNT,#RPTBFE ; buffer full? BNE 500$ ; no -> skip .PUSH R5 ; save WRITE #RPTFDB,ERROR=1000$ ; output file INC FDB.BL(R5) ; bump block number MOV #RPTBUF,RPTPNT ; reset pointer .POP R5 ; save 500$: RETURN ; done ; 1000$: FATAL ; .SBTTL Data Structures and Variables ; ; .PSECT FDB$$$ ; open special area ; ====== ====== ; ; FDB NAME=RPTFDB,CHANNEL=13.,BUFFER=RPTBUF,SIZE=400 RPTFLG: .WORD 0 ; 1 -> suppress output RPTPNT: .WORD RPTBUF ; store pointer RPTBUF: ; I/O buffer RPTNME: .ASCIZ /LST:REPORT.LST/ ; Selection report file default name .BLKB 1000-<.-RPTBUF> ; rest of buffer RPTBFE: ; END OF BUFFER ; .END