From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- pkg/utilities/nttools/tproject/nextuniq.x | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 pkg/utilities/nttools/tproject/nextuniq.x (limited to 'pkg/utilities/nttools/tproject/nextuniq.x') 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 + +# 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 -- cgit