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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
include <tbset.h>
include "tbtables.h"
include "tblerr.h"
# Write values for one column to a range of rows.
#
# Phil Hodge, 28-Dec-1987 Different data types combined into one file.
# Phil Hodge, 3-Feb-1992 Add option for text table type.
# Phil Hodge, 31-Mar-1993 Include short datatype.
# Phil Hodge, 4-Nov-1993 Include check that row is > 0.
# Phil Hodge, 3-Apr-1995 Set TB_MODIFIED to true.
# Phil Hodge, 23-Jun-1995 Modify for FITS tables;
# change declaration of buffer in tbcptt to 2-D array.
# Phil Hodge, 29-Jul-1997 Call tbtwer for fits tables.
# Phil Hodge, 3-Mar-1998 Modify to allow for row selector.
# tbcptd -- putcol double
# Write values for one column to a range of rows. This is for data type
# double precision.
procedure tbcptd (tp, cp, buffer, sel_firstrow, sel_lastrow)
pointer tp # i: pointer to table descriptor
pointer cp # i: pointer to descriptor of the column
double buffer[ARB] # i: array of values to be put into column
int sel_firstrow # i: first row into which to put values
int sel_lastrow # i: last row into which to put values
#--
int firstrow, lastrow # range of actual row numbers
int row, i
errchk tbswer, tbxcpd, tbycpd, tbzcpd, tbfapd
begin
if (TB_READONLY(tp))
call error (ER_TBREADONLY, "can't write to table; it's readonly")
if (sel_lastrow < sel_firstrow)
call error (1, "tbcptd: lastrow is less than firstrow")
# If we're writing beyond EOF, write extra rows and update TB_NROWS.
# Also convert to actual row numbers.
call tbswer (tp, sel_lastrow, lastrow)
call tbswer (tp, sel_firstrow, firstrow)
if (TB_TYPE(tp) == TBL_TYPE_S_ROW) {
call tbxcpd (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_S_COL) {
call tbycpd (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_TEXT) {
call tbzcpd (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_FITS) {
i = 1
do row = firstrow, lastrow {
call tbfapd (tp, cp, row, buffer[i], 1, 1)
i = i + 1
}
} else {
call error (ER_TBCORRUPTED, "tbcptd: table type is messed up")
}
TB_MODIFIED(tp) = true
end
# tbcptr -- putcol real
# Write values for one column to a range of rows. This is for data type real.
procedure tbcptr (tp, cp, buffer, sel_firstrow, sel_lastrow)
pointer tp # i: pointer to table descriptor
pointer cp # i: pointer to descriptor of the column
real buffer[ARB] # i: array of values to be put into column
int sel_firstrow # i: first row into which to put values
int sel_lastrow # i: last row into which to put values
#--
int firstrow, lastrow # range of actual row numbers
int row, i
errchk tbswer, tbxcpr, tbycpr, tbzcpr, tbfapr
begin
if (TB_READONLY(tp))
call error (ER_TBREADONLY, "can't write to table; it's readonly")
if (sel_lastrow < sel_firstrow)
call error (1, "tbcptr: lastrow is less than firstrow")
# If we're writing beyond EOF, write extra rows and update TB_NROWS.
# Also convert to actual row numbers.
call tbswer (tp, sel_lastrow, lastrow)
call tbswer (tp, sel_firstrow, firstrow)
if (TB_TYPE(tp) == TBL_TYPE_S_ROW) {
call tbxcpr (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_S_COL) {
call tbycpr (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_TEXT) {
call tbzcpr (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_FITS) {
i = 1
do row = firstrow, lastrow {
call tbfapr (tp, cp, row, buffer[i], 1, 1)
i = i + 1
}
} else {
call error (ER_TBCORRUPTED, "tbcptr: table type is messed up")
}
TB_MODIFIED(tp) = true
end
# tbcpti -- putcol integer
# Write values for one column to a range of rows. This is for data type
# integer.
procedure tbcpti (tp, cp, buffer, sel_firstrow, sel_lastrow)
pointer tp # i: pointer to table descriptor
pointer cp # i: pointer to descriptor of the column
int buffer[ARB] # i: array of values to be put into column
int sel_firstrow # i: first row into which to put values
int sel_lastrow # i: last row into which to put values
#--
int firstrow, lastrow # range of actual row numbers
int row, i
errchk tbswer, tbxcpi, tbycpi, tbzcpi, tbfapi
begin
if (TB_READONLY(tp))
call error (ER_TBREADONLY, "can't write to table; it's readonly")
if (sel_lastrow < sel_firstrow)
call error (1, "tbcpti: lastrow is less than firstrow")
# If we're writing beyond EOF, write extra rows and update TB_NROWS.
# Also convert to actual row numbers.
call tbswer (tp, sel_lastrow, lastrow)
call tbswer (tp, sel_firstrow, firstrow)
if (TB_TYPE(tp) == TBL_TYPE_S_ROW) {
call tbxcpi (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_S_COL) {
call tbycpi (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_TEXT) {
call tbzcpi (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_FITS) {
i = 1
do row = firstrow, lastrow {
call tbfapi (tp, cp, row, buffer[i], 1, 1)
i = i + 1
}
} else {
call error (ER_TBCORRUPTED, "tbcpti: table type is messed up")
}
TB_MODIFIED(tp) = true
end
# tbcpts -- putcol short
# Write values for one column to a range of rows. This is for data type
# short integer.
procedure tbcpts (tp, cp, buffer, sel_firstrow, sel_lastrow)
pointer tp # i: pointer to table descriptor
pointer cp # i: pointer to descriptor of the column
short buffer[ARB] # i: array of values to be put into column
int sel_firstrow # i: first row into which to put values
int sel_lastrow # i: last row into which to put values
#--
int firstrow, lastrow # range of actual row numbers
int row, i
errchk tbswer, tbxcps, tbycps, tbzcps, tbfaps
begin
if (TB_READONLY(tp))
call error (ER_TBREADONLY, "can't write to table; it's readonly")
if (sel_lastrow < sel_firstrow)
call error (1, "tbcpts: lastrow is less than firstrow")
# If we're writing beyond EOF, write extra rows and update TB_NROWS.
# Also convert to actual row numbers.
call tbswer (tp, sel_lastrow, lastrow)
call tbswer (tp, sel_firstrow, firstrow)
if (TB_TYPE(tp) == TBL_TYPE_S_ROW) {
call tbxcps (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_S_COL) {
call tbycps (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_TEXT) {
call tbzcps (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_FITS) {
i = 1
do row = firstrow, lastrow {
call tbfaps (tp, cp, row, buffer[i], 1, 1)
i = i + 1
}
} else {
call error (ER_TBCORRUPTED, "tbcpts: table type is messed up")
}
TB_MODIFIED(tp) = true
end
# tbcptb -- putcol Boolean
# This is for data type boolean.
procedure tbcptb (tp, cp, buffer, sel_firstrow, sel_lastrow)
pointer tp # i: pointer to table descriptor
pointer cp # i: pointer to descriptor of the column
bool buffer[ARB] # i: array of values to be put into column
int sel_firstrow # i: first row into which to put values
int sel_lastrow # i: last row into which to put values
#--
int firstrow, lastrow # range of actual row numbers
int row, i
errchk tbswer, tbxcpb, tbycpb, tbzcpb, tbfapb
begin
if (TB_READONLY(tp))
call error (ER_TBREADONLY, "can't write to table; it's readonly")
if (sel_lastrow < sel_firstrow)
call error (1, "tbcptb: lastrow is less than firstrow")
# If we're writing beyond EOF, write extra rows and update TB_NROWS.
# Also convert to actual row numbers.
call tbswer (tp, sel_lastrow, lastrow)
call tbswer (tp, sel_firstrow, firstrow)
if (TB_TYPE(tp) == TBL_TYPE_S_ROW) {
call tbxcpb (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_S_COL) {
call tbycpb (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_TEXT) {
call tbzcpb (tp, cp, buffer, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_FITS) {
i = 1
do row = firstrow, lastrow {
call tbfapb (tp, cp, row, buffer[i], 1, 1)
i = i + 1
}
} else {
call error (ER_TBCORRUPTED, "tbcptb: table type is messed up")
}
TB_MODIFIED(tp) = true
end
# tbcptt -- putcol text
# Write values for one column to a range of rows. This is for character
# strings.
procedure tbcptt (tp, cp, buffer, lenstr, sel_firstrow, sel_lastrow)
pointer tp # i: pointer to table descriptor
pointer cp # i: pointer to descriptor of the column
char buffer[lenstr,ARB] # i: array of values to be put into column
int lenstr # i: number of char in each element of buffer
int sel_firstrow # i: first row into which to put values
int sel_lastrow # i: last row into which to put values
#--
int firstrow, lastrow # range of actual row numbers
int row, i
errchk tbswer, tbxcpt, tbycpt, tbzcpt, tbfapt
begin
if (TB_READONLY(tp))
call error (ER_TBREADONLY, "can't write to table; it's readonly")
if (sel_lastrow < sel_firstrow)
call error (1, "tbcptt: lastrow is less than firstrow")
# If we're writing beyond EOF, write extra rows and update TB_NROWS.
# Also convert to actual row numbers.
call tbswer (tp, sel_lastrow, lastrow)
call tbswer (tp, sel_firstrow, firstrow)
if (TB_TYPE(tp) == TBL_TYPE_S_ROW) {
call tbxcpt (tp, cp, buffer, lenstr, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_S_COL) {
call tbycpt (tp, cp, buffer, lenstr, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_TEXT) {
call tbzcpt (tp, cp, buffer, lenstr, firstrow, lastrow)
} else if (TB_TYPE(tp) == TBL_TYPE_FITS) {
i = 1
do row = firstrow, lastrow {
call tbfapt (tp, cp, row, buffer[1,i], lenstr, 1, 1)
i = i + 1
}
} else {
call error (ER_TBCORRUPTED, "tbcptt: table type is messed up")
}
TB_MODIFIED(tp) = true
end
|