aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/tbxncn.x
blob: 69a650f7d3838aeae6f227836f67cfdb81de1906 (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
include "tbtables.h"

# tbxncn -- new column null
# Write INDEF values for each new column in each existing row of a table.
# This is called after defining new columns in an open table, but only if
# it contains some rows and the record length did not have to be increased.
#
# Phil Hodge, 30-Mar-1993  indef_rec is now TY_CHAR rather than TY_REAL.

procedure tbxncn (tp, old_colused, indef_rec)

pointer tp			# i: Pointer to table descriptor
int	old_colused		# i: Previous value of TB_COLUSED (unit=SZ_CHAR)
char	indef_rec[ARB]		# i: INDEF record buffer
#--
long	locn			# Location (chars) for writing in table
int	start			# Location in INDEF record of values to write
int	k			# Loop index
int	num_chars		# Number of chars to write as INDEF

begin
	num_chars = TB_COLUSED(tp) - old_colused

	start = old_colused + 1			# unit = SZ_CHAR
	locn = TB_BOD(tp) + old_colused		# incremented in loop
	do k = 1, TB_NROWS(tp) {
	    call seek (TB_FILE(tp), locn)
	    call write (TB_FILE(tp), indef_rec[start], num_chars)
	    locn = locn + TB_ROWLEN(tp)
	}
end