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 /pkg/tbtables/tbznll.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/tbtables/tbznll.x')
-rw-r--r-- | pkg/tbtables/tbznll.x | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/pkg/tbtables/tbznll.x b/pkg/tbtables/tbznll.x new file mode 100644 index 00000000..2f45b88d --- /dev/null +++ b/pkg/tbtables/tbznll.x @@ -0,0 +1,56 @@ +include "tbtables.h" +include "tblerr.h" + +# tbznll -- set rows to null +# This procedure sets all columns in a range of rows to INDEF. +# If the first row to be deleted is greater than the last row, or if +# the range of rows is outside the allocated size of the table, nothing +# is done. It is not considered an error if the first row is less than +# one or the last row is greater than the number of allocated rows in +# the table. +# +# Phil Hodge, 3-Feb-1992 Subroutine created. + +procedure tbznll (tp, firstrow, lastrow) + +pointer tp # i: pointer to table descriptor +int firstrow # i: first row to be set to INDEF +int lastrow # i: last row to be set to INDEF +#-- +pointer cp # pointer to a column descriptor +int row1, row2 # firstrow, lastrow truncated to 1, nrows +int row # loop index for row number +int col # loop index for column number +int datatype # data type of a column +int lenstr # length of a string table element +int ip # offset to a string in Memc +pointer tbcnum() + +begin + row1 = max (1, firstrow) + row2 = min (TB_ALLROWS(tp), lastrow) + + # Set each column value in each row to INDEF. + do col = 1, TB_NCOLS(tp) { + cp = tbcnum (tp, col) + datatype = COL_DTYPE(cp) + + if (datatype == TBL_TY_DOUBLE) { + do row = row1, row2 + Memd[COL_OFFSET(cp) + row - 1] = INDEFD + + } else if (datatype == TBL_TY_INT) { + do row = row1, row2 + Memi[COL_OFFSET(cp) + row - 1] = INDEFI + + } else if (datatype < 0) { + do row = row1, row2 { + lenstr = -COL_DTYPE(cp) # not including EOS + ip = (row - 1) * (lenstr + 1) # including EOS + Memc[COL_OFFSET(cp) + ip] = EOS + } + } else { + call error (ER_TBCOLBADTYP, "tbznll: bad datatype") + } + } +end |