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

# tbxwer -- write empty rows
# The purpose of this routine is to write empty (INDEF) rows beyond the
# current end of file for a row-ordered table, if the specified row is
# larger than the number of rows already written to the table.  If the
# specified row is within the range of existing rows, the table itself
# will not be modified.
#
# Note that TB_NROWS will not be updated.
#
# Phil Hodge,  4-Mar-1998  Subroutine created, extracted from tbtwer.

procedure tbxwer (tp, rownum)

pointer tp		# i: pointer to table descriptor
int	rownum		# i: (actual) row number in table
#--
long	locn		# location for writing (at EOF)
int	k		# loop index
int	nrows		# number of rows on entry to this routine
int	rowlen		# record length
errchk	seek, write

begin
	nrows  = TB_NROWS(tp)
	if (rownum <= nrows)
	    return				# nothing to do

	rowlen = TB_ROWLEN(tp)
	locn = TB_BOD(tp) + nrows * rowlen	# this is the end of file
	do k = nrows+1, rownum {
	    call seek (TB_FILE(tp), locn)
	    call write (TB_FILE(tp), Memc[TB_INDEF(tp)], rowlen)
	    locn = locn + rowlen
	}
end