aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/tmatch/rowname.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/tmatch/rowname.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'pkg/utilities/nttools/tmatch/rowname.x')
-rw-r--r--pkg/utilities/nttools/tmatch/rowname.x61
1 files changed, 61 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/tmatch/rowname.x b/pkg/utilities/nttools/tmatch/rowname.x
new file mode 100644
index 00000000..484fcd75
--- /dev/null
+++ b/pkg/utilities/nttools/tmatch/rowname.x
@@ -0,0 +1,61 @@
+#* HISTORY *
+#* B.Simon 26-Aug-94
+
+# ROWNAME -- Create name for table row by concatenating column values
+
+procedure rowname (in, irow, ncol, col, name, namelen)
+
+pointer in # i: table descriptor
+int irow # i: table row number
+int ncol # i: number of table columns
+pointer col[ARB] # i: table column pointers
+char name[ARB] # o: concatenated values of columns
+int namelen # i: maximum name length
+#--
+int ic, jc, icol
+pointer sp, value
+
+begin
+ # Allocate memory for column buffer
+
+ call smark (sp)
+ call salloc (value, SZ_LINE, TY_CHAR)
+
+ # Concatenate column values into name string
+
+ jc = 0
+ icol = 0
+ for (ic = 1; ic <= namelen; ic = ic + 1) {
+
+ # A value of zero is a flag to read the next coumn
+
+ if (jc == 0) {
+ icol = icol + 1
+ if (icol > ncol) {
+ if (ic > 1)
+ ic = ic - 1 # remove trailing blank
+
+ break
+ }
+
+ call tbegtt (in, col[icol], irow, Memc[value], SZ_LINE)
+ }
+
+ # Copy a single character from the buffer to the output string
+ # until the buffer is exhausted. At this point we copy a blank
+ # as a spacer and set the value of jc as a flag to read the
+ # next column.
+
+ if (Memc[value+jc] == EOS) {
+ name[ic] = ' '
+ jc = 0
+ } else {
+ name[ic] = Memc[value+jc]
+ jc = jc + 1
+ }
+ }
+
+ name[ic] = EOS
+ call sfree (sp)
+end
+