home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / vrac_os2 / thedjg22.zip / WORDS.THE < prev   
Text File  |  1996-05-26  |  2KB  |  51 lines

  1. /*
  2. $Id: words.the 2.1 1995/06/24 16:31:45 MH Rel MH $
  3. */
  4. /***********************************************************************/
  5. /* Description: REXX macro to count the number of words to a target.   */
  6. /* Syntax:      words [target]                                         */
  7. /* Notes:       This macro counts the number of words to the specified */
  8. /*              target.                                                */
  9. /*              Full XEDIT/KEDIT/THE targets are supported.            */
  10. /***********************************************************************/
  11. Trace o
  12. Parse Arg args
  13. If Words(args) = 0 Then args = 1
  14. reply = valid_target(args)
  15. If reply = 'ERROR' Then
  16.    Do
  17.      'EMSG Error: 17 Invalid target' args
  18.      Exit
  19.    End
  20. If reply = 'NOTFOUND' Then
  21.    Do
  22.      'EMSG Error: 17 Target not found' args
  23.      Exit
  24.    End
  25. 'preserve'
  26. start_line = Word(reply,1)
  27. nolines = Word(reply,2)
  28. forward = 1                  /* assume direction is forward by defualt */
  29. 'EXTRACT /LINE/SIZE/STAY/'                        /* get various stuff */
  30. current_line = line.1                   /* save current line for later */
  31. If nolines < 0 Then Do                /* if target before current line */
  32.    forward = 0                    /* indicate direction to be backward */
  33.    nolines = nolines * -1                     /* make nolines positive */
  34. End
  35. ':'||start_line
  36. totwords = 0                             /* reset changed line counter */
  37. Do nolines                              /* for each line to target ... */
  38.    'EXTRACT /CURLINE/TOF/EOF'        /* get current line contents, etc.*/
  39.    If tof.1 = 'ON',                    /* ignore line if on TOF or EOF */
  40.    |  eof.1 = 'ON' Then nop
  41.    Else
  42.       totwords = totwords + Words(curline.3)
  43.    If forward = 1 Then 'N'         /* if going forward, get next line */
  44.    Else 'U'                  /* if going backwards, get previous line */
  45.    If rc \= 0 Then Leave                        /* shouldn't get here */
  46. End
  47. 'MSG' totwords 'words counted'
  48. If stay.1 = 'ON' Then ':'||current_line 
  49. 'restore'
  50. Return                                              /* go back to THE */
  51.