diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /vo/votools/colbyid.cl | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'vo/votools/colbyid.cl')
-rw-r--r-- | vo/votools/colbyid.cl | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/vo/votools/colbyid.cl b/vo/votools/colbyid.cl new file mode 100644 index 00000000..2316ecb5 --- /dev/null +++ b/vo/votools/colbyid.cl @@ -0,0 +1,51 @@ +#{ COLBYID -- Find the column number (1-indexed) containing the specified +# value of the ID attribute. + +procedure colbyid (table, id) + +string table { prompt = "Table name" } +string id { prompt = "ID attribute" } + +int column = 0 { prompt = "Found column number (or -1)"} +string ucd = "" { prompt = "Found column UCD" } +string name = "" { prompt = "Found column Name" } +bool print = no { prompt = "Print the field number?" } +bool found = no { prompt = "Was attribute found??" } + +begin + string ltab, lid + int nfound + + ltab = table # get parameters + lid = id + column = -1 + nfound = 0 + + tinfo (ltab, ttout-) # get table info + for (i=1; i <= tinfo.ncols; i=i+1) { + keypar (ltab, "TID" // i, >& "dev$null") + found = keypar.found + if (keypar.found == yes && keypar.value == lid) { + if (nfound == 0) { + column = i + + keypar (ltab, "TTYPE" // i, >& "dev$null") + name = "" + if (keypar.found == yes) + name = keypar.value + + keypar (ltab, "TUCD" // i, >& "dev$null") + ucd = "" + if (keypar.found == yes) + ucd = keypar.value + } + nfound = nfound + 1 + } + } + + if (nfound > 1) + printf ("Warning: %d columns found with ID='%s'\n", nfound, id) + + if (print) + print (column) +end |