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
|
#* HISTORY *
#* B.Simon 26-Aug-94
# ROWNAME -- Create name for table row by concatenating column values
procedure rowname (in, irow, ncol, col, name, namelen)
pointer in # i: table descriptor
int irow # i: table row number
int ncol # i: number of table columns
pointer col[ARB] # i: table column pointers
char name[ARB] # o: concatenated values of columns
int namelen # i: maximum name length
#--
int ic, jc, icol
pointer sp, value
begin
# Allocate memory for column buffer
call smark (sp)
call salloc (value, SZ_LINE, TY_CHAR)
# Concatenate column values into name string
jc = 0
icol = 0
for (ic = 1; ic <= namelen; ic = ic + 1) {
# A value of zero is a flag to read the next coumn
if (jc == 0) {
icol = icol + 1
if (icol > ncol) {
if (ic > 1)
ic = ic - 1 # remove trailing blank
break
}
call tbegtt (in, col[icol], irow, Memc[value], SZ_LINE)
}
# Copy a single character from the buffer to the output string
# until the buffer is exhausted. At this point we copy a blank
# as a spacer and set the value of jc as a flag to read the
# next column.
if (Memc[value+jc] == EOS) {
name[ic] = ' '
jc = 0
} else {
name[ic] = Memc[value+jc]
jc = jc + 1
}
}
name[ic] = EOS
call sfree (sp)
end
|