1/* 2$Id: total.the,v 1.2 2004/08/07 04:28:33 mark Exp $ 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/***********************************************************************/ 11Trace o 12Numeric Digits 20 /* to make really sure that we don't get overflow */ 13'EXTRACT /BLOCK/FILENAME/FPATH/' 14If block.0 = 1 Then Do 15 'EMSG No Marked block' 16 Return 17 End 18If block.1 \= 'BOX' & block.1 \= 'COLUMN' Then Do 19 'EMSG No Marked BOX or COLUMN block' 20 Return 21 End 22current_file = fpath.1||filename.1 23If current_file \= block.6 Then Do 24 'EMSG Marked block not in current file' 25 Return 26 End 27Do i = block.2 To block.4 28 'NOMSG :'||i 29 If rc = 0 Then Leave 30End 31tot. = 0 32Do Forever 33 'EXTRACT /CURLINE/LINE/EOF' 34 If line.1 > block.4 Then Leave 35 If eof.1 = 'YES' Then Leave 36 num = Substr(curline.3,block.3,block.5-block.3+1) 37 Do i = 1 To Words(num) 38 If Datatype(Word(num,i),'NUM') Then tot.i = tot.i + Word(num,i) 39 End 40 if Words(num) > tot.0 Then tot.0 = Words(num) 41 'N' 42End 43'U' 44line = '' 45Do i = 1 To tot.0 46 line = line tot.i 47End 48/* 49 * Determine correct right alignment 50 */ 51len = Length(line) 52spaces = block.5-len 53If spaces > 0 Then line = Copies(' ',spaces)line 54'i' line 55'N' 56Return 57