aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/copyone/tabpar.x
blob: a4f452c37925d270b502d5260302642da81dab46 (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
include	<tbset.h>
define	SZ_KEYWORD	64

# TABPAR -- Transfer a table element to an IRAF parameter
#
# B.Simon	17-Aug-1987	First Code
# Phil Hodge	15-May-2002	Add 'format' parameter.

procedure t_tabpar ()

pointer	table		# Name of table
pointer	column		# Name of column
int	row		# Row number of element in the table
bool	format		# Format the value using table print format?
pointer	value		# Value of table element
bool	undef		# Is table element undefined?

int	eltype
pointer	sp, hd

bool	clgetb()
int	clgeti()
pointer	tbtopn()

begin
	# Allocate storage for character strings

	call smark (sp)
	call salloc (table, SZ_FNAME, TY_CHAR)
	call salloc (column, SZ_COLNAME, TY_CHAR)
	call salloc (value, SZ_KEYWORD, TY_CHAR)

	# Read input parameters

	call clgstr ("table", Memc[table], SZ_FNAME)
	call clgstr ("column", Memc[column], SZ_COLNAME)
	row = clgeti ("row")
	format = clgetb ("format")

	# Read the table element as a character string

	hd = tbtopn (Memc[table], READ_ONLY, NULL)
	call gettabdat (hd, Memc[column], row, SZ_KEYWORD, format,
			Memc[value], undef, eltype)
	call tbtclo (hd)

	# Write output parameters and free string storage

	call addslash (Memc[value], SZ_KEYWORD)
	call clpstr ("value", Memc[value])
	call clputb ("undef", undef)
	call sfree (sp)
	return
end