File: total.the

package info (click to toggle)
the 3.1-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,452 kB
  • ctags: 5,268
  • sloc: ansic: 63,118; sh: 2,399; makefile: 444
file content (49 lines) | stat: -rw-r--r-- 1,422 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
$Id: total.the,v 1.1 2001/01/04 09:42:24 mark Exp $
*/
/***********************************************************************/
/* Description: REXX macro to sum numbers in a marked block.           */
/* Syntax:      total                                                  */
/* Notes:       This macro will sum the numbers in the marked block    */
/*              and insert a new line with the total at the end of the */
/*              block.                                                 */
/***********************************************************************/
Trace o
'EXTRACT /BLOCK/FILENAME/FPATH/'
If block.0 = 1 Then Do
   'EMSG No Marked block'
   Return
   End
If block.1 \= 'BOX' & block.1 \= 'COLUMN' Then Do
   'EMSG No Marked BOX or COLUMN block'
   Return
   End
current_file = fpath.1||filename.1
If current_file \= block.6 Then Do
   'EMSG Marked block not in current file'
   Return
   End
Do i = block.2 To block.4
   'NOMSG :'||i
   If rc = 0 Then Leave
End
tot. = 0
Do Forever
   'EXTRACT /CURLINE/LINE/EOF'
   If line.1 > block.4 Then Leave
   If eof.1 = 'YES' Then Leave
   num = Substr(curline.3,block.3,block.5-block.3+1)
   Do i = 1 To Words(num)
      If Datatype(Word(num,i),'NUM') Then tot.i = tot.i + Word(num,i)
   End
   if Words(num) > tot.0 Then tot.0 = Words(num)
   'N'
End
'U'
line = ''
Do i = 1 To tot.0
   line = line tot.i
End
'i' Copies(' ',block.3-1)||line
'N'
Return