home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / theos215.zip / total.the < prev    next >
Text File  |  1993-09-19  |  1KB  |  38 lines

  1. /*
  2. $Header: C:\THE\RCS\total.the 1.4 1993/09/01 16:27:20 MH Interim MH $
  3. */
  4. /***********************************************************************/
  5. /* Description: REXX macro to sum numbers in a marked block.           */
  6. /* Syntax:      total                                                  */
  7. /* Notes:       This macro will sum the numbers in the marked block    */
  8. /*              and insert a new line with the total at the end of the */
  9. /*              block.                                                 */
  10. /***********************************************************************/
  11. Trace o
  12. 'EXTRACT /BLOCK/FNAME/FPATH/'
  13. If block.0 = 1 Then Do
  14.    'EMSG No Marked block'
  15.    Return
  16.    End
  17. If block.1 \= 'BOX' Then Do
  18.    'EMSG No Marked BOX block'
  19.    Return
  20.    End
  21. current_file = fpath.1||fname.1
  22. If current_file \= block.6 Then Do
  23.    'EMSG Marked block not in current file'
  24.    Return
  25.    End
  26. ':'||block.2
  27. tot = 0
  28. Do i = block.2 To block.4
  29.    'EXTRACT /CURLINE/'
  30.    num = Substr(curline.3,block.3,block.5-block.3+1)
  31.    If Datatype(num,'NUM') Then tot = tot + num
  32.    'N'
  33. End
  34. 'U'
  35. 'i' Copies(' ',block.3-1)||tot
  36. 'N'
  37. Return
  38.