aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/threed/tiimage/tmhc.x
blob: 30ad4eb358ac465dbb28db26462aa3099c7d89ff (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
include <tbset.h>

#  TM_HC  --  Get column name from image header and copy image into table.
#
#
#
#
#  Revision history:
#  ----------------
#  30-Jan-97  -  Task created (I.Busko)


procedure tm_hc (tp, cp, ncp, row, rflag, im)

pointer	tp		# table pointer
pointer	cp		# column pointer array
int	ncp		# size of column pointer array
int	row		# row where to begin insertion
bool	rflag		# use row number in header ?
pointer	im		# image pointer
#--
pointer	sp, colname, cn, duma
int	i, dumi
bool	match

errchk	tm_header, tm_copy

bool	streq()

begin
	call smark (sp)
	call salloc (colname, SZ_COLNAME, TY_CHAR)
	call salloc (cn, SZ_COLNAME, TY_CHAR)
	call salloc (duma, max(SZ_COLUNITS,SZ_COLFMT),TY_CHAR)

	# Get column name from image header.
	call tm_header (im, Memc[colname], Memc[duma], Memc[duma])

	# Loop over table columns.
	match = false
	do i = 1, ncp {

	    # Get column name from table.
	    call tbcinf (Memi[cp+i-1], dumi, Memc[cn], Memc[duma], 
                        Memc[duma], dumi, dumi, dumi)

	    # Copy array if names match.
	    if (streq (Memc[colname], Memc[cn])) {
	        call tm_copy (tp, Memi[cp+i-1], row, rflag, im)
	        match = true
	    }
	}
	if (!match)
	    call error (1, "No column matched.")

	call sfree (sp)
end