aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/selector/tbcnel.x
blob: 9173a1ff6063045a7d94982c769a0044d7501cee (plain) (blame)
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
50
51
52
include <tbset.h>

# This file contains tbcnel and tbcnel1.

# tbcnel -- get the total number of elements for a column
# This function multiplies the number of selected rows by the number of
# elements in one row, for the specified column.  The column may contain
# scalars or arrays.
#
# If the column was listed in a column selector string, and if this
# included an array section, the number of elements for one row will be
# the number in the array section.
#
# Phil Hodge,  5-Mar-1998  Function created.

int procedure tbcnel (tp, cp)

pointer tp		# i: pointer to table descriptor
pointer cp		# i: pointer to column descriptor
#--
pointer descrip		# column selector descriptor (ignored)
int	nrows		# number of selected rows
int	nelem		# number of elements in one cell

begin
	call tbcnel1 (tp, cp, descrip, nelem, nrows)

	return (nrows * nelem)
end

procedure tbcnel1 (tp, cp, descrip, nelem, nrows)

pointer tp		# i: pointer to table descriptor
pointer cp		# i: pointer to column descriptor
pointer descrip		# o: column selector descriptor
int	nelem		# o: number of elements in one cell
int	nrows		# o: number of selected rows
#--
pointer tbcdes()
int	tcs_totsize()
int	tbpsta(), tbalen()

begin
	descrip = tbcdes (tp, cp)

	if (descrip == NULL)
	    nelem = tbalen (cp)			# cp is not a selected column
	else
	    nelem = tcs_totsize (descrip)

	nrows = tbpsta (tp, TBL_NROWS)		# number of selected rows
end