aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/ptools/txtools/t_txdump.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 /noao/digiphot/ptools/txtools/t_txdump.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'noao/digiphot/ptools/txtools/t_txdump.x')
-rw-r--r--noao/digiphot/ptools/txtools/t_txdump.x45
1 files changed, 45 insertions, 0 deletions
diff --git a/noao/digiphot/ptools/txtools/t_txdump.x b/noao/digiphot/ptools/txtools/t_txdump.x
new file mode 100644
index 00000000..8d2b332e
--- /dev/null
+++ b/noao/digiphot/ptools/txtools/t_txdump.x
@@ -0,0 +1,45 @@
+# T_TXDUMP -- Procedure to perform a relational select operation upon a set of
+# records within a text file. Our function is to select all records from the
+# input file matching some criterion, printing the listed fields on the
+# standard output. Dumping the keywords and reheadersting is optional.
+
+procedure t_txdump ()
+
+pointer textfile # list of input text files
+pointer fields # list of fields to be dumped
+pointer expr # boolean expression to be evaluated
+int headers # format the output
+int parameters # print the headers
+
+int list, fd
+pointer sp
+bool clgetb()
+int clpopnu(), clgfil(), open(), btoi()
+
+begin
+ # Allocate working space.
+ call smark (sp)
+ call salloc (textfile, SZ_FNAME, TY_CHAR)
+ call salloc (fields, SZ_LINE, TY_CHAR)
+ call salloc (expr, SZ_LINE, TY_CHAR)
+
+ # Get the parameters.
+ list = clpopnu ("textfiles")
+ call clgstr ("fields", Memc[fields], SZ_LINE)
+ call strupr (Memc[fields])
+ call clgstr ("expr", Memc[expr], SZ_LINE)
+ headers = btoi (clgetb ("headers"))
+ parameters = btoi (clgetb ("parameters"))
+
+ # Select records.
+ while (clgfil (list, Memc[textfile], SZ_FNAME) != EOF) {
+ fd = open (Memc[textfile], READ_ONLY, TEXT_FILE)
+ if (Memc[fields] != EOS)
+ call pt_xdump (fd, Memc[fields], Memc[expr], headers,
+ parameters)
+ call close (fd)
+ }
+
+ call clpcls (list)
+ call sfree (sp)
+end