diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /vo/votools/colbyucd.cl | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'vo/votools/colbyucd.cl')
-rw-r--r-- | vo/votools/colbyucd.cl | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/vo/votools/colbyucd.cl b/vo/votools/colbyucd.cl new file mode 100644 index 00000000..051b2d78 --- /dev/null +++ b/vo/votools/colbyucd.cl @@ -0,0 +1,51 @@ +#{ COLBYUCD -- Find the column number (1-indexed) containing the specified +# value of the UCD attribute. + +procedure colbyucd (table, ucd) + +string table { prompt = "Table name" } +string ucd { prompt = "UCD attribute" } + +int column = 0 { prompt = "Found column number (or -1)"} +string name = "" { prompt = "found column name" } +string id = "" { prompt = "found column ID" } +bool print = no { prompt = "Print the field number?" } +bool found = no { prompt = "Was attribute found??" } + +begin + string ltab, lucd + int nfound + + ltab = table # get parameters + lucd = ucd + column = -1 + nfound = 0 + + tinfo (ltab, ttout-) # get table info + for (i=1; i <= tinfo.ncols; i=i+1) { + keypar (ltab, "TUCD" // i, >& "dev$null") + found = keypar.found + if (keypar.found == yes && keypar.value == lucd) { + if (nfound == 0) { + column = i + + keypar (ltab, "TTYPE" // i, >& "dev$null") + name = "" + if (keypar.found == yes) + name = keypar.value + + keypar (ltab, "TID" // i, >& "dev$null") + id = "" + if (keypar.found == yes) + id = keypar.value + } + nfound = nfound + 1 + } + } + + if (nfound > 1) + printf ("Warning: %d columns found with UCD='%s'\n", nfound, ucd) + + if (print) + print (column) +end |