aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/tbrudf.x
blob: 447600de29489bb2a1e09d8dac28bd316387173e (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
58
59
60
61
62
63
64
65
66
include <tbset.h>
include "tbtables.h"
include "tblerr.h"

# tbrudf -- set to undefined
# "Delete" entries in a table by setting each entry to the INDEF value
# appropriate for its datatype.
#
# Phil Hodge,  4-Nov-1993  Include check on valid row number.
# Phil Hodge,  3-Apr-1995  Set TB_MODIFIED to true.
# Phil Hodge, 15-Jun-1995  Modify for FITS tables.
# Phil Hodge,  3-Jun-1996  Errchk tbfudf; call tbtwer if beyond EOF.
# Phil Hodge,  3-Mar-1998  Modify to allow for row selector.
# Phil Hodge, 26-Jun-1998  Change test (rownum < 1) to (selrow < 1).

procedure tbrudf (tp, colptr, numcols, selrow)

pointer tp			# i: pointer to table descriptor
pointer colptr[ARB]		# i: array of pointers to column descriptors
int	numcols			# i: number of columns
int	selrow			# i: row number (or selected row number)
#--
int	rownum			# actual row number
int	rst_rownum()
errchk	rst_rownum, tbswer, tbfudf, tbxudf, tbyudf, tbzudf

begin
	if (TB_READONLY(tp))
	    call error (ER_TBREADONLY,
			"tbrudf:  can't delete entries in readonly table")

	if (selrow < 1)
	    call error (1, "tbrudf:  row number must be > 0")

	# If the row is beyond EOF, write extra rows and update TB_NROWS.
	# Then we're done, because the new rows are already INDEF.
	if (TB_ROW_SELECT(tp) == YES) {

	    if (selrow > TB_NSEL_ROWS(tp)) {
		call tbswer (tp, selrow, rownum)
		return
	    }
	    rownum = rst_rownum (TB_ROWSET(tp), selrow)

	} else {

	    rownum = selrow
	    if (rownum > TB_NROWS(tp)) {
		call tbswer (tp, selrow, rownum)
		return
	    }
	}

	if (TB_TYPE(tp) == TBL_TYPE_S_ROW)
	    call tbxudf (tp, colptr, numcols, rownum)
	else if (TB_TYPE(tp) == TBL_TYPE_S_COL)
	    call tbyudf (tp, colptr, numcols, rownum)
	else if (TB_TYPE(tp) == TBL_TYPE_TEXT)
	    call tbzudf (tp, colptr, numcols, rownum)
	else if (TB_TYPE(tp) == TBL_TYPE_FITS)
	    call tbfudf (tp, colptr, numcols, rownum)
	else
	    call error (ER_TBCORRUPTED, "tbrudf:  table type is messed up")

	TB_MODIFIED(tp) = true
end