aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/photcal/mctable/mctget.gx
diff options
context:
space:
mode:
Diffstat (limited to 'noao/digiphot/photcal/mctable/mctget.gx')
-rw-r--r--noao/digiphot/photcal/mctable/mctget.gx46
1 files changed, 46 insertions, 0 deletions
diff --git a/noao/digiphot/photcal/mctable/mctget.gx b/noao/digiphot/photcal/mctable/mctget.gx
new file mode 100644
index 00000000..f79379c8
--- /dev/null
+++ b/noao/digiphot/photcal/mctable/mctget.gx
@@ -0,0 +1,46 @@
+include "../lib/mctable.h"
+
+
+$for (csilrdxp)
+# MCT_GET - Get a single value from the table (generic).
+
+PIXEL procedure mct_get$t (table, row, col)
+
+pointer table # table descriptor
+int row # row number
+int col # column number
+
+pointer mct_getrow()
+errchk mct_getrow()
+
+begin
+ # Check pointer and magic number.
+ if (table == NULL)
+ call error (0, "mct_get: Null table pointer")
+ if (MCT_MAGIC (table) != MAGIC)
+ call error (0, "mct_get: Bad magic number")
+
+ # Check the table type.
+ if (MCT_TYPE (table) != TY_PIXEL)
+ call error (0, "mct_get: Wrong table type")
+
+ # Check the row and column range.
+ if (row < 1 || row > MCT_NPROWS (table))
+ call error (0, "mct_get: Bad row number")
+ if (row == MCT_NPROWS (table) && (col < 1 || col > MCT_NPCOLS (table)))
+ call error (0, "mct_get: Bad column number at last row")
+ if (row != MCT_NPROWS (table) && (col < 1 || col > MCT_MAXCOL (table)))
+ call error (0, "mct_get: Bad column number")
+
+ # Update the counters.
+ MCT_NGROWS (table) = row
+ MCT_NGCOLS (table) = col
+
+ # Return value.
+ $if (datatype == p)
+ return (MEMP[mct_getrow (table, row) + col - 1])
+ $else
+ return (Mem$t[mct_getrow (table, row) + col - 1])
+ $endif
+end
+$endfor