aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/ptools/pconcat.cl
blob: 7d098eeed4b441b61f1bd5c94fd994e2dca2e3d3 (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
# PCONCAT -- Concatenate a list of apphot/daophot databases into a single
# output database. The input files must either be all text files or all data
# files. PCONCAT checks that the input files were all created by the same
# task.

procedure pconcat (infiles, outfile)

file	infiles {prompt = "Input apphot/daophot database(s) to be concatenated"}
file	outfile {prompt = "Output apphot/daophot database"}
string	task	{"TASK", prompt="Task name keyword"}

struct	*inlist

begin
	# Declare local variables.
	bool	table, text, other
	file	in, out
	string	tmpin, inname

	# Cache the istable parameters.
	cache ("istable")

	# Get the positional parameters.
	in = infiles
	out = outfile

	# Make a file lists.
	tmpin = mktemp ("tmp$")
	files (in, sort=no, > tmpin)

	# Check to see whether the first file is a text database or a table.

	inlist = tmpin
	if (fscan (inlist, inname) != EOF) {
	    istable (inname)
	    table = istable.table
	    text = istable.text
	    other = istable.other
	} else {
	    table = no
	    text = no
	    other = no
	}
	delete (tmpin, ver-, >& "dev$null")
	inlist = ""

	# Do the actual appending.
	if (table)
	    tbconcat (in, out, task=task)
	else if (text)
	    txconcat (in, out, task=task)
	else if (access (inname))
	    print ("File " // inname // " is not an APPHOT/DAOPHOT database")
	else
	    print ("File " // inname // " does not exist")
end