aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/tproject/nextuniq.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/utilities/nttools/tproject/nextuniq.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'pkg/utilities/nttools/tproject/nextuniq.x')
-rw-r--r--pkg/utilities/nttools/tproject/nextuniq.x39
1 files changed, 39 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/tproject/nextuniq.x b/pkg/utilities/nttools/tproject/nextuniq.x
new file mode 100644
index 00000000..2a2b8e8d
--- /dev/null
+++ b/pkg/utilities/nttools/tproject/nextuniq.x
@@ -0,0 +1,39 @@
+include <tbset.h>
+
+# NEXTUNIQ -- Retrieve the next unique row from a table
+
+procedure nextuniq (tp, numptr, colptr, irow)
+
+pointer tp # i: Table descriptor
+int numptr # i: Number of column pointers
+pointer colptr[ARB] # i: Array of column pointers
+int irow # u: Current unique row
+#--
+bool fold
+int jrow, krow, nrow
+
+data fold / false /
+
+int tbpsta(), tbrcmp()
+
+begin
+ # Get number of rows in table
+
+ nrow = tbpsta (tp, TBL_NROWS)
+
+ # Loop until a row that does not match the preceding rows is found
+
+ for (jrow = irow+1; jrow <= nrow; jrow = jrow + 1) {
+ for (krow = 1; krow < jrow; krow = krow + 1) {
+ if (tbrcmp (tp, numptr, colptr, fold, jrow, krow) == 0)
+ break
+ }
+
+ if (krow == jrow)
+ break
+ }
+
+ # Set irow to the first row that does not match any preceding row
+
+ irow = jrow
+end