aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/tbswer1.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/tbswer1.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'pkg/tbtables/tbswer1.x')
-rw-r--r--pkg/tbtables/tbswer1.x53
1 files changed, 53 insertions, 0 deletions
diff --git a/pkg/tbtables/tbswer1.x b/pkg/tbtables/tbswer1.x
new file mode 100644
index 00000000..edc04459
--- /dev/null
+++ b/pkg/tbtables/tbswer1.x
@@ -0,0 +1,53 @@
+include <tbset.h>
+include "tbtables.h"
+
+# tbswer1 -- write empty rows, maybe
+
+# This routine is like tbswer with one significant difference. If the row
+# to be written (selrow) is equal to the current number of rows plus one,
+# and if the table is an stsdas type row-ordered table, then this routine
+# does NOT write an INDEF row to the table and does NOT update TB_NROWS.
+# This is to improve efficiency for this common case, so that the row
+# does not need to be written twice (once INDEF, then the actual data).
+# Routines such as tbxap[] may take advantage of this option.
+#
+# For other cases, this routine just calls tbswer, which does write INDEF
+# rows to the table and does update TB_NROWS.
+#
+# If a row selector is in effect, selrow will be converted to rownum, and
+# new rows (if rownum is beyond EOF) will be added to the set of selected
+# rows. If there is no row selector, the value of selrow will be assigned
+# directly to rownum.
+#
+# Phil Hodge, 4-Mar-1998 Subroutine created.
+
+procedure tbswer1 (tp, selrow, rownum)
+
+pointer tp # i: pointer to table descriptor
+int selrow # i: row number (or selected row number)
+int rownum # o: actual row number
+#--
+errchk tbsrow, tbswer
+
+begin
+ if (TB_TYPE(tp) == TBL_TYPE_S_ROW) {
+
+ if (TB_ROW_SELECT(tp) == YES) {
+
+ if (selrow > TB_NSEL_ROWS(tp) + 1)
+ call tbswer (tp, selrow, rownum)
+ else
+ call tbsrow (tp, selrow, rownum) # TB_NROWS not updated
+
+ } else {
+
+ rownum = selrow
+ if (rownum > TB_NROWS(tp) + 1)
+ call tbswer (tp, selrow, rownum)
+ }
+
+ } else {
+
+ call tbswer (tp, selrow, rownum)
+ }
+end