aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/tbxwer.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /pkg/tbtables/tbxwer.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'pkg/tbtables/tbxwer.x')
-rw-r--r--pkg/tbtables/tbxwer.x37
1 files changed, 37 insertions, 0 deletions
diff --git a/pkg/tbtables/tbxwer.x b/pkg/tbtables/tbxwer.x
new file mode 100644
index 00000000..bb06e9c1
--- /dev/null
+++ b/pkg/tbtables/tbxwer.x
@@ -0,0 +1,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