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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
include <tbset.h>
include "tbtables.h"
include "tblerr.h"
# Get a parameter from the table header.
#
# Phil Hodge, 28-Dec-1987 Different data types combined into one file.
# Phil Hodge, 9-Mar-1989 Change dtype from char to int.
# Phil Hodge, 22-Jan-1993 Change "== INDEFD" to "IS_INDEFD".
# Phil Hodge, 15-Dec-1994 Allow converting from text string parameter.
# Phil Hodge, 30-Mar-1995 Include keyword name in error message.
# Phil Hodge, 8-Jun-1995 Modify for FITS tables.
# Phil Hodge, 7-Jun-1999 In tbhgtb, check for "yes", "y", "no", "n",
# "true", "t", "false", "f" if a numerical value was not
# found and data type is text.
# tbhgtb -- get Boolean header parameter
# Get a parameter from the table header. This is for data type bool.
bool procedure tbhgtb (tp, keyword)
pointer tp # i: pointer to table descriptor
char keyword[ARB] # i: name of parameter to get
#--
pointer sp
pointer par # buffer for header record for parameter
pointer errmess # scratch for possible error message
int dtype # data type
int parnum # parameter number (> 0 if keyword was found)
double dblval # buffer for reading value from string
bool bval # buffer for value
int nscan()
bool streq()
errchk tbhfkr, tbfhgb
begin
if (TB_TYPE(tp) == TBL_TYPE_FITS) {
call tbfhgb (tp, keyword, bval)
return (bval)
}
call smark (sp)
call salloc (par, SZ_PARREC, TY_CHAR)
call tbhfkr (tp, keyword, dtype, Memc[par], parnum) # find keyword
if (parnum > 0) {
dblval = INDEFD
call sscan (Memc[par])
call gargd (dblval) # read the value as a double
if (nscan() < 1 && dtype == TY_CHAR) {
call strlwr (Memc[par])
if (streq (Memc[par], "yes") || streq (Memc[par], "y") ||
streq (Memc[par], "true") || streq (Memc[par], "t")) {
dblval = double(YES)
} else if (streq (Memc[par], "no") || streq (Memc[par], "n") ||
streq (Memc[par], "false") || streq (Memc[par], "f")) {
dblval = double(NO)
}
}
} else {
call salloc (errmess, SZ_LINE, TY_CHAR)
call sprintf (Memc[errmess], SZ_LINE,
"tbhgtb: table header parameter `%s' not found")
call pargstr (keyword)
call error (ER_TBPARNOTFND, Memc[errmess])
}
call sfree (sp)
if (IS_INDEFD (dblval))
return (false)
else if (nint(dblval) == YES)
return (true)
else
return (false)
end
# tbhgtd -- get double header parameter
# Get a parameter from the table header. This is for data type double.
double procedure tbhgtd (tp, keyword)
pointer tp # i: pointer to table descriptor
char keyword[ARB] # i: name of parameter to get
#--
pointer sp
pointer par # buffer for header record for parameter
pointer errmess # scratch for possible error message
int dtype # data type
int parnum # parameter number (> 0 if keyword was found)
double dblval # buffer for reading value from string
errchk tbhfkr, tbfhgd
begin
if (TB_TYPE(tp) == TBL_TYPE_FITS) {
call tbfhgd (tp, keyword, dblval)
return (dblval)
}
call smark (sp)
call salloc (par, SZ_PARREC, TY_CHAR)
call tbhfkr (tp, keyword, dtype, Memc[par], parnum) # find keyword
if (parnum > 0) {
dblval = INDEFD
call sscan (Memc[par])
call gargd (dblval)
} else {
call salloc (errmess, SZ_LINE, TY_CHAR)
call sprintf (Memc[errmess], SZ_LINE,
"tbhgtd: table header parameter `%s' not found")
call pargstr (keyword)
call error (ER_TBPARNOTFND, Memc[errmess])
}
call sfree (sp)
return (dblval)
end
# tbhgti -- get integer header parameter
# Get a parameter from the table header. This is for data type int.
int procedure tbhgti (tp, keyword)
pointer tp # i: pointer to table descriptor
char keyword[ARB] # i: name of parameter to get
#--
pointer sp
pointer par # buffer for header record for parameter
pointer errmess # scratch for possible error message
int dtype # data type
int parnum # parameter number (> 0 if keyword was found)
double dblval # buffer for reading value from string
int ival
errchk tbhfkr, tbfhgi
begin
if (TB_TYPE(tp) == TBL_TYPE_FITS) {
call tbfhgi (tp, keyword, ival)
return (ival)
}
call smark (sp)
call salloc (par, SZ_PARREC, TY_CHAR)
call tbhfkr (tp, keyword, dtype, Memc[par], parnum) # find keyword
if (parnum > 0) {
dblval = INDEFD
call sscan (Memc[par])
call gargd (dblval) # read the value as a double
} else {
call salloc (errmess, SZ_LINE, TY_CHAR)
call sprintf (Memc[errmess], SZ_LINE,
"tbhgti: table header parameter `%s' not found")
call pargstr (keyword)
call error (ER_TBPARNOTFND, Memc[errmess])
}
call sfree (sp)
if (IS_INDEFD (dblval))
return (INDEFI)
else
return (nint(dblval))
end
# tbhgtr -- get real header parameter
# Get a parameter from the table header. This is for data type real.
real procedure tbhgtr (tp, keyword)
pointer tp # i: pointer to table descriptor
char keyword[ARB] # i: name of parameter to get
#--
pointer sp
pointer par # buffer for header record for parameter
pointer errmess # scratch for possible error message
int dtype # data type
int parnum # parameter number (> 0 if keyword was found)
real realval # buffer for reading value from string
errchk tbhfkr, tbfhgr
begin
if (TB_TYPE(tp) == TBL_TYPE_FITS) {
call tbfhgr (tp, keyword, realval)
return (realval)
}
call smark (sp)
call salloc (par, SZ_PARREC, TY_CHAR)
call tbhfkr (tp, keyword, dtype, Memc[par], parnum) # find keyword
if (parnum > 0) {
realval = INDEFR
call sscan (Memc[par])
call gargr (realval)
} else {
call salloc (errmess, SZ_LINE, TY_CHAR)
call sprintf (Memc[errmess], SZ_LINE,
"tbhgtr: table header parameter `%s' not found")
call pargstr (keyword)
call error (ER_TBPARNOTFND, Memc[errmess])
}
call sfree (sp)
return (realval)
end
# tbhgtt -- get character header parameter
# Get a parameter from the table header. This is for character data type.
procedure tbhgtt (tp, keyword, text, maxch)
pointer tp # i: pointer to table descriptor
char keyword[ARB] # i: name of parameter
char text[ARB] # o: value of parameter
int maxch # i: maximum number of characters to get
#--
pointer sp
pointer par # buffer for header record for parameter
pointer errmess # scratch for possible error message
int dtype # data type
int parnum # parameter number (> 0 if keyword was found)
errchk tbhfkr, tbfhgt
begin
if (TB_TYPE(tp) == TBL_TYPE_FITS) {
call tbfhgt (tp, keyword, text, maxch)
return
}
call smark (sp)
call salloc (par, SZ_PARREC, TY_CHAR)
call tbhfkr (tp, keyword, dtype, Memc[par], parnum) # find keyword
if (parnum > 0) {
call strcpy (Memc[par], text, maxch)
} else {
call salloc (errmess, SZ_LINE, TY_CHAR)
call sprintf (Memc[errmess], SZ_LINE,
"tbhgtt: table header parameter `%s' not found")
call pargstr (keyword)
call error (ER_TBPARNOTFND, Memc[errmess])
}
call sfree (sp)
end
|