home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / fortran / ratfor.lbr / WRDCNT.RTF < prev   
Text File  |  1986-04-27  |  640b  |  49 lines

  1. # wordcount - count words in standard input
  2.  
  3.   define(EOF,-1)
  4.   define(YES,1)
  5.   define(NO,0)
  6.   define(BLANK,32)
  7.   define(NEWLINE,10)
  8.   define(TAB,9)
  9.   define(character,byte)
  10.  
  11.    character getc
  12.    character c
  13.    integer inword, wc
  14.  
  15.    call initio
  16.  
  17.    wc = 0
  18.    inword = NO
  19.    while (getc(c) != EOF)
  20.       if (c == BLANK | c == NEWLINE | c == TAB)
  21.      inword = NO
  22.       else if (inword == NO) {
  23.      inword = YES
  24.      wc = wc + 1
  25.      }
  26.    call putdec(wc, 1)
  27.    call putc(NEWLINE)
  28.    call putc(EOF)
  29.    stop
  30.    end
  31. 
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.