;*************************************************
; LINANA.M68 - Input line analysis program
;              (great outline for file analysis)
; Usage: .LINANA input-line
; by Dave Heyliger
;**************************************************

      SEARCH SYS                 ; search the normals
      SEARCH SYSSYM
      SEARCH SYSSYM

      PHDR    -1,0,PH$REE!PH$REU    ; define program header

      .OFINI                     ; define some variables....
      .OFDEF  CHARS,4            ; # of characters in the line
      .OFDEF  NUMS,4             ; # of numbers in the line
      .OFDEF  SPACES,4           ; # of spaces in the line
      .OFSIZ  IMPSIZ             ; IMPSIZ is 16. bytes in size

      GETIMP  IMPSIZ,A5          ; A5 points to variable base
      CLR     CHARS(A5)          ; initialize all counts to 0
      CLR     NUMS(A5)
      CLR     SPACES(A5)

      LIN                        ; just a CR?
      BNE     LOOK               ; nope, there's some input!
      TYPECR  <Usage:  .LINANA input-line>
      EXIT                       ; yes, message and quit

LOOK:  CMPB    @A2,#15            ; at the CR?
      BEQ     STATS              ; yes, output the stats
      CMPB    @A2,#40            ; at a " "?
      BNE     10$                ; nope
      INC     SPACES(A5)         ; yes, increment space count
      BR      NEXT               ; and get next character
10$:   ALF                        ; A2 point to A...z???
      BNE     20$                ; nope
      INC     CHARS(A5)          ; yes, increment character count
      BR      NEXT               ; and get next character
20$:   NUM                        ; A2 point to a numeric value?
      BNE     30$                ; nope
      INC     NUMS(A5)           ; yes, increment numeric count
NEXT:  INC     A2                 ; point A2 to next character on line
      BR      LOOK               ; and look again

STATS: TYPECR  <The input line had the following:>
      TYPE    <     Number of Alpha characters: >
      MOV     CHARS(A5),D1       ; get number of alphabet characters
      DCVT    0,OT$TRM           ; output number to screen
      CRLF                       ; and a RETURN
      TYPE    <     Number of Numeric characters: >
      MOV     NUMS(A5),D1        ; get number of number characters
      DCVT    0,OT$TRM           ; output number to screen
      CRLF                       ; and a RETURN
      TYPE    <     Number of Spaces: >
      MOV     SPACES(A5),D1      ; get number of spaces
      DCVT    0,OT$TRM           ; output number to screen
      CRLF                       ; and a RETURN
      EXIT                       ; back to the dot
      END                        ; end of program