home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / CDRom / PET-CDW2.DMS / in.adf / rexx / Word-Count-File.ced < prev   
Encoding:
Text File  |  1993-07-07  |  1.2 KB  |  62 lines

  1. /*
  2. ** Word-Count-File.ced
  3. **
  4. ** $VER: Word-Count-File.ced 1.0.1 (27.04.93)
  5. **
  6. ** This script counts the number of words in the currently loaded
  7. ** file.
  8. **
  9. ** This script requires CygnusEd Professional v3.5 (or later) to run.
  10. **
  11. ** Copyright © 1990-1993 ASDG, Incorporated  All Rights Reserved
  12. */
  13.  
  14.  
  15. OPTIONS RESULTS
  16.  
  17.  
  18. NL = '0A'X
  19.  
  20. CEDTOFRONT
  21. OKAY2 "This is not a particularly fast way of counting" || NL ||,
  22.     "words, but it does work.  Do you really want to" || NL ||,
  23.     "do this?"
  24. IF (RESULT = 0) THEN DO
  25.     CEDTOFRONT
  26.     OKAY1 "Word Count Aborted"
  27.     EXIT 10
  28. END
  29.  
  30. BEG OF FILE
  31.  
  32. STATUS NUMLINES
  33. NumberOfLines = RESULT
  34. WordCount = 0
  35. i = 1
  36.  
  37. DO WHILE (i <= NumberOfLines)
  38.     STATUS LINEBUFFER
  39.     WordCount = WordCount + WORDS( RESULT )
  40.     DOWN
  41.     i = i + 1
  42.     LASTKEY
  43.     /* Check for a keystroke (~= -1) which is not an key release (< 128) */
  44.     IF (RESULT ~= -1) & (WORD( RESULT, 1 ) < 128) THEN DO
  45.         CEDTOFRONT
  46.         OKAY1 "Word Count Aborted"
  47.         EXIT 10
  48.     END
  49.     DM "Hitting any key will abort the word count.  Line "i", word "WordCount"."
  50. END
  51. DM ""
  52.  
  53. IF (NumberOfLines = 1) THEN
  54.     LineString = "Line"
  55. ELSE
  56.     LineString = "Lines"
  57.  
  58. CEDTOFRONT
  59. OKAY1 "Counted" WordCount "Words In" NumberOfLines LineString
  60.  
  61. EXIT 0
  62.