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/tquery/wquery.x | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 pkg/utilities/nttools/tquery/wquery.x (limited to 'pkg/utilities/nttools/tquery/wquery.x') diff --git a/pkg/utilities/nttools/tquery/wquery.x b/pkg/utilities/nttools/tquery/wquery.x new file mode 100644 index 00000000..33cc25ff --- /dev/null +++ b/pkg/utilities/nttools/tquery/wquery.x @@ -0,0 +1,50 @@ +include + +# WQUERY -- Copy selected columns and rows to output table +# +# B.Simon 19-Oct-87 First Code + +procedure wquery (itp, otp, numcol, colptr, nindex, index) + +pointer itp # i: Input table descriptor +pointer otp # i: Output table descriptor +int numcol # i: Number of column pointers +pointer colptr[ARB] # i: Array of column pointers +int nindex # i: Size of index array +int index[ARB] # i: Array of row indices +#-- +int iptr, idx, jdx +int colnum[1], datatype[1], lendata[1], lenfmt[1] +pointer sp, ocp, newcol, colname, colunits, colfmt + +begin + # Set up arrays in dynamic memory + + call smark (sp) + call salloc (newcol, numcol, TY_INT) + call salloc (colname, SZ_COLNAME, TY_CHAR) + call salloc (colunits, SZ_COLUNITS, TY_CHAR) + call salloc (colfmt, SZ_COLFMT, TY_CHAR) + + + # Copy column information from the input table to the output table + + do iptr = 1, numcol { + call tbcinf (colptr[iptr], colnum, Memc[colname], Memc[colunits], + Memc[colfmt], datatype[1], lendata[1], lenfmt[1]) + call tbcdef (otp, ocp, Memc[colname], Memc[colunits], Memc[colfmt], + datatype[1], lendata[1], 1) + Memi[newcol+iptr-1] = ocp + } + + # Copy the table columns a row at a time + + call tbtcre (otp) + call tbhcal (itp, otp) + do idx = 1, nindex { + jdx = index[idx] + call tbrcsc (itp, otp, colptr, Memi[newcol], jdx, idx, numcol) + } + + call sfree (sp) +end -- cgit