aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/threed/titable/generic/tirowss.x
blob: 91c678c3a6861c2e690addb208fb858f3b119275 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
include	<tbset.h>

#
# TIROWS  --  Expand row selector into array and copy it into output 
#             table cell.
#
#
#
#
#  Revision history:
#  ----------------
#  20-Jan-1997  -  Task created (I.Busko)
#   7-Feb-2000  -  For datatype = 'c', make buf an array of strings (P.Hodge)


procedure tirowss (itp, icp, otp, ocp, rowsel, orow, len, buf)

pointer	itp		# i: input table descriptor
pointer	icp		# i: input column descriptor
pointer	otp		# i: output table descriptor
pointer	ocp		# i: output column descriptor
char	rowsel[ARB]	# i: row selector
int	orow		# i: row in output table where to write into
int	len		# i: buffer length
short	buf[ARB]
#--
double	undefd
real	undefr
pointer	pcode
int	undefi, i, nelem, irow, numrow, alength
short	undefs

pointer	trsopen()
int	tbpsta(), tbalen()
bool	trseval()

begin
	# Loop over selected rows on input table.
	pcode  = trsopen (itp, rowsel)
	numrow = tbpsta (itp, TBL_NROWS)
	nelem = 0
	do irow = 1, numrow {
	    if (trseval (itp, irow, pcode)) {
	        nelem = nelem + 1
	        if (nelem > len) {
	            nelem = len
	            break
	        }
	        # Get element and store in buffer.
	        call tbegts (itp, icp, irow, buf[nelem])
	    }
	}
	call trsclose (pcode)

	# Write buffer into array cell element.
	call tbapts (otp, ocp, orow, buf, 1, nelem)

	# If number of selected rows in current input table
	# is smaller than output table array length, fill
	# remaining array elements with INDEF.
	alength = tbalen (ocp)
	if (alength > nelem) {
	    undefd = INDEFD
	    undefr = INDEFR
	    undefi = INDEFI
	    undefs = INDEFS
	    do i = nelem+1, alength {
	        call tbapts (otp, ocp, orow, undefs, i, 1)
	    }
	}
end