blob: f79379c8bfa26cf31ca0b234000022914c96e43c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
|