home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 7 Games / 07-Games.zip / hangman1.zip / texthang.cmd < prev   
OS/2 REXX Batch file  |  1996-03-12  |  944b  |  45 lines

  1. /* Plane English text -> hangman data */
  2. /* TEXTHANG.CMD by The Creative CAT 1996 */
  3.  
  4. if arg() < 1 then do
  5.   say 'Usage : TEXTHANG source destination min max'
  6.   exit
  7. end
  8.  
  9. arg sourcefile destfile minch maxch
  10.  
  11. count = 0
  12. do while (lines(sourcefile) = 1) & (count < 10000)
  13.   s = linein(sourcefile)
  14.   ii = words(s) - 1
  15.   do i = 2 to ii
  16.     w = translate(word(s, i))
  17.     b = verify(w, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
  18.     l = length(w)
  19.     if (b = 0) & (l >= minch) & (l <= maxch) then do
  20.       call lineout 'hangman.$$1', w
  21.       count = count + 1
  22.     end
  23.   end
  24. end
  25.  
  26. call stream sourcefile, 'C', 'close'
  27. call stream 'hangman.$$1', 'C', 'close'
  28.  
  29. 'sort < hangman.$$1 > hangman.$$2'
  30.  
  31. erase 'hangman.$$1'
  32.  
  33. ss = ''
  34. do while lines('hangman.$$2') = 1
  35.   s = linein('hangman.$$2')
  36.   if \(s = ss) then do
  37.     call lineout destfile, s
  38.     ss = s
  39.   end
  40. end
  41.  
  42. call stream 'hangman.$$2', 'C', 'close'
  43.  
  44. erase 'hangman.$$2'
  45.