diff options
Diffstat (limited to 'pkg/utilities/nttools/tquery/wquery.x')
-rw-r--r-- | pkg/utilities/nttools/tquery/wquery.x | 50 |
1 files changed, 50 insertions, 0 deletions
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 <tbset.h> + +# 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 |