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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
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)
$if (datatype == c)
procedure tirowst (itp, icp, otp, ocp, rowsel, orow, maxch, len, buf)
$else
procedure tirows$t (itp, icp, otp, ocp, rowsel, orow, len, buf)
$endif
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
$if (datatype == c)
int maxch # i: max length of string
$endif
int len # i: buffer length
$if (datatype == c)
char buf[maxch,ARB] # i: work buffer
$else
PIXEL buf[ARB]
$endif
#--
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.
$if (datatype == c)
call tbegtt (itp, icp, irow, buf[1,nelem], maxch)
$else
call tbegt$t (itp, icp, irow, buf[nelem])
$endif
}
}
call trsclose (pcode)
# Write buffer into array cell element.
$if (datatype == c)
call tbaptt (otp, ocp, orow, buf, maxch, 1, nelem)
$else
call tbapt$t (otp, ocp, orow, buf, 1, nelem)
$endif
# 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 {
$if (datatype == c)
call tbaptt (otp, ocp, orow, "", maxch, i, 1)
$endif
$if (datatype == b)
call tbaptb (otp, ocp, orow, false, i, 1)
$endif
$if (datatype == dris)
call tbapt$t (otp, ocp, orow, undef$t, i, 1)
$endif
}
}
end
|