; ************************** AMUS Program Label ******************************
; Filename: DOCSIZ.M68 Date: 01/23/90
; Category: UTIL Hash Code: 621-607-334-122 Version: 1.0(101)
; Initials: ULTR/AM Name: DAVID PALLMANN
; Company: ULTRASOFT CORPORATION Telephone #: 5163484848
; Related Files:
; Min. Op. Sys.: AMOS/L 1.0 Expertise Level: BEG
; Special:
; Description: Shows characters, words, lines, and pages in a document. Can
; process AlphaWRITE, SuperVue, and text files.
; ****************************************************************************
;****************************************************************************
;* *
;* DOCSIZ *
;* Report various statistics about the size of a document *
;* *
;****************************************************************************
;Copyright (C) 1990 UltraSoft Corp. All Rights Reserved.
;
;Written by: David Pallmann
;
;Edit History:
;1.0(100) 22-Jan-90 created. /DFP
;1.0(101) 22-Jan-90 ignore AlphaWRITE control sequences. /DFP
VMAJOR =1
VMINOR =0
VSUB =0
VEDIT =101.
VWHO =0
SEARCH SYS
SEARCH SYSSYM
;ASCII character definitions
$LF =12 ; line feed
$FF =14 ; form feed
$CR =15 ; carriage return
;AlphaWRITE 2.0 command byte definitions
C$CTL =^H0F2 ; start of control sequence
C$CTE =^H0F3 ; end of control sequence
C$PAG =^H0F5 ; Page break (hard, inserted by user)
C$BRK =^H0F6 ; Page break (soft, inserted by WRITE)
C$CHP =^H0F7 ; Page break (new chapter)
OPEN: OPENI FILE(A5) ;
CALL BYPHDR ; bypass header if there is one
;set up for processing
SETUP: MOV #1,PAGES(A5) ; always at least one page
CLR LINES(A5) ; clear line count
CLR WORDS(A5) ; clear word count
CLR CHARS(A5) ; clear character count
;get a character and act upon it
GET: CTRLC CLOSE ; ^C check
FILINB FILE(A5) ; get a byte
TST FILE+D.SIZ(A5) ; end of file?
JEQ CLOSE ; yes
;if an AlphaWRITE document, bypass control sequences
PROCES: INC CHARS(A5) ; update character count
CALL UPDWRD ; update word count
CALL UPDLIN ; update line count
CALL UPDPAG ; update page count
BR GET ;
;close file
CLOSE: CLOSE FILE(A5) ;
;report our findings
REPORT: MOV CHARS(A5),D1 ;
DCVT 0,OT$TRM!OT$TSP ;
TYPE <character> ;
CALL PLURAL ;
TYPE <, > ;
MOV WORDS(A5),D1 ;
DCVT 0,OT$TRM!OT$TSP ;
TYPE <word> ;
CALL PLURAL ;
TYPE <, > ;
MOV LINES(A5),D1 ;
DCVT 0,OT$TRM!OT$TSP ;
TYPE <line> ;
CALL PLURAL ;
TYPE <, > ;
MOV PAGES(A5),D1 ;
DCVT 0,OT$TRM!OT$TSP ;
TYPE <page> ;
CALL PLURAL ;
CRLF ;
CRLF ;
EXIT: EXIT ;
USAGE: TYPECR Document size utility
TYPECR Copyright (C) 1990 UltraSoft Corporation. All Rights Reserved.
CRLF ;
TYPECR Usage: .DOCSIZ docname ;
CRLF ;
TYPECR <Compatible with AlphaWRITE, SuperVUE, and text files.>
CRLF ;
EXIT ;
NOT.FOUND:
TYPECR Document not found - please try again and specify an extension
CRLF ;
EXIT ;
;************
;* BYPHDR *
;************
;Function: Bypass header if document has one
;
;Inputs: FILE+D.EXT(A5) - extension of file
BYPHDR: CMPW FILE+D.EXT(A5),#[WRT] ; AlphaWRITE document?
BNE 20$ ; no
MOV #508.,D0 ; load loop count
10$: FILINB FILE(A5) ; get and discard header byte
SOB D0,10$ ; loop
20$: RTN ; return
;************
;* UPDWRD *
;************
;Function: Update word count
;
;Inputs: D1 - character from file
;
;Outputs: WORDS(A5) - updated
UPDWRD: CALL WRDCHR ; is this a word character?
BEQ INAWRD ; yes
;we are not in a word
ENDWRD: TSTB INWORD(A5) ; were we in a word?
BEQ UW.RTN ; yes
INC WORDS(A5) ;
CLRB INWORD(A5) ;
BR UW.RTN ;
;we are in a word
INAWRD: MOVB #1,INWORD(A5) ; set the in-a-word flag
UW.RTN: RTN ; return
;************
;* WRDCHR *
;************
;Function: Indicate whether or not we have a word character
;
;Inputs: D1 - character
;
;Outputs: Z - set if character is a word character
;************
;* UPDLIN *
;************
;Function: Update line count if we are at the end of a line
;
;Inputs: D1 - character read from file
; FILE+D.EXT(A5) - extension of file
;
;Outputs: LINES(A5) - updated
UL.ASC: CMPB D1,#$LF ; line feed?
BEQ UL.INC ; yes - increment line count
RTN ; return
UL.WRT: TSTB D1 ; AlphaWRITE end of line?
BEQ UL.INC ; yes - increment line count
RTN ; return
UL.SV: CMPB D1,#$CR ; SuperVUE end of line?
BEQ UL.INC ; yes - increment line count
RTN ; return
UL.INC: INC LINES(A5) ; increment line count
CLRB INWORD(A5) ; clear "in a word" flag
RTN ; return
;************
;* UPDPAG *
;************
;Function: Update page count if we are at the end of a page
;
;Inputs: D1 - character read from file
; FILE+D.EXT(A5) - extension of file
;
;Outputs: PAGES(A5) - updated