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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
include <mach.h> # for MAX_INT and MAX_SHORT
include <tbset.h>
include "tbtables.h"
# tbzgt[tbirds] -- get a single element
# This procedure gets a single element from an internal buffer corresponding
# to a value in a text file.
#
# Phil Hodge, 14-Jan-1992 Subroutines created.
# Phil Hodge, 10-Feb-1993 Change "NO" to "false" in tbzgtb.
# Phil Hodge, 31-Mar-1993 Include short datatype.
# Phil Hodge, 12-Aug-1993 Use ctol instead of ctoi to allow leading "+" sign.
# Phil Hodge, 14-Apr-1998 Use COL_FMT directly, instead of calling tbcftg.
procedure tbzgtb (tp, cp, rownum, buffer)
pointer tp # i: pointer to table descriptor
pointer cp # i: pointer to column descriptor
int rownum # i: row number
bool buffer # o: buffer for value to be gotten
#--
pointer sp
pointer cbuf # buffer for copying character elements
int lenstr # length of a string table element
int ip # offset for extracting a string in Memc
int ctowrd()
bool streq()
begin
if (COL_DTYPE(cp) == TBL_TY_DOUBLE) {
buffer = (nint (Memd[COL_OFFSET(cp) + rownum - 1]) != NO)
} else if (COL_DTYPE(cp) == TBL_TY_INT) {
buffer = (Memi[COL_OFFSET(cp) + rownum - 1] != NO)
} else { # string
call smark (sp)
call salloc (cbuf, SZ_FNAME, TY_CHAR)
lenstr = -COL_DTYPE(cp) + 1 # one for EOS
ip = (rownum - 1) * lenstr + 1
if (ctowrd (Memc[COL_OFFSET(cp)], ip, Memc[cbuf], SZ_FNAME) < 1) {
buffer = false # bug fix 10-Feb-1993 PEH
} else {
call strlwr (Memc[cbuf])
buffer = streq (Memc[cbuf], "yes") ||
streq (Memc[cbuf], "true")
}
call sfree (sp)
}
end
procedure tbzgtd (tp, cp, rownum, buffer)
pointer tp # i: pointer to table descriptor
pointer cp # i: pointer to column descriptor
int rownum # i: row number
double buffer # o: buffer for value to be gotten
#--
int ival # buffer for integer value
int lenstr # length of a string table element
int ip # offset for extracting a string in Memc
int ctod()
begin
if (COL_DTYPE(cp) == TBL_TY_DOUBLE) {
buffer = Memd[COL_OFFSET(cp) + rownum - 1]
} else if (COL_DTYPE(cp) == TBL_TY_INT) {
ival = Memi[COL_OFFSET(cp) + rownum - 1]
if (IS_INDEFI(ival))
buffer = INDEFD
else
buffer = ival
} else { # string
lenstr = -COL_DTYPE(cp) + 1 # one for EOS
ip = (rownum - 1) * lenstr + 1
if (ctod (Memc[COL_OFFSET(cp)], ip, buffer) < 1)
buffer = INDEFD
}
end
procedure tbzgtr (tp, cp, rownum, buffer)
pointer tp # i: pointer to table descriptor
pointer cp # i: pointer to column descriptor
int rownum # i: row number
real buffer # o: buffer for value to be gotten
#--
double dval # buffer for double precision
int ival # buffer for integer value
int lenstr # length of a string table element
int ip # offset for extracting a string in Memc
int ctor()
begin
if (COL_DTYPE(cp) == TBL_TY_DOUBLE) {
dval = Memd[COL_OFFSET(cp) + rownum - 1]
if (IS_INDEFD(dval))
buffer = INDEFR
else
buffer = dval
} else if (COL_DTYPE(cp) == TBL_TY_INT) {
ival = Memi[COL_OFFSET(cp) + rownum - 1]
if (IS_INDEFI(ival))
buffer = INDEFR
else
buffer = ival
} else { # string
lenstr = -COL_DTYPE(cp) + 1 # one for EOS
ip = (rownum - 1) * lenstr + 1
if (ctor (Memc[COL_OFFSET(cp)], ip, buffer) < 1)
buffer = INDEFR
}
end
procedure tbzgti (tp, cp, rownum, buffer)
pointer tp # i: pointer to table descriptor
pointer cp # i: pointer to column descriptor
int rownum # i: row number
int buffer # o: buffer for value to be gotten
#--
double dval # buffer for double precision
int lenstr # length of a string table element
int ip # offset for extracting a string in Memc
long lval # so we can use ctol
int ctol()
begin
if (COL_DTYPE(cp) == TBL_TY_DOUBLE) {
dval = Memd[COL_OFFSET(cp) + rownum - 1]
if (IS_INDEFD(dval) || (abs (dval) > MAX_INT))
buffer = INDEFI
else
buffer = nint (dval)
} else if (COL_DTYPE(cp) == TBL_TY_INT) {
buffer = Memi[COL_OFFSET(cp) + rownum - 1]
} else { # string
lenstr = -COL_DTYPE(cp) + 1 # one for EOS
ip = (rownum - 1) * lenstr + 1
if (ctol (Memc[COL_OFFSET(cp)], ip, lval) > 0)
buffer = lval
else
buffer = INDEFI
#*** if (ctoi (Memc[COL_OFFSET(cp)], ip, buffer) < 1)
#*** buffer = INDEFI
}
end
procedure tbzgts (tp, cp, rownum, buffer)
pointer tp # i: pointer to table descriptor
pointer cp # i: pointer to column descriptor
int rownum # i: row number
short buffer # o: buffer for value to be gotten
#--
double dval # buffer for double precision
int lenstr # length of a string table element
int ip # offset for extracting a string in Memc
int ival
long lval # so we can use ctol
int ctol()
begin
if (COL_DTYPE(cp) == TBL_TY_DOUBLE) {
dval = Memd[COL_OFFSET(cp) + rownum - 1]
if (IS_INDEFD(dval) || (abs (dval) > MAX_SHORT))
buffer = INDEFS
else
buffer = nint (dval)
} else if (COL_DTYPE(cp) == TBL_TY_INT) {
ival = Memi[COL_OFFSET(cp) + rownum - 1]
if (IS_INDEFI(ival) || (abs (ival) > MAX_SHORT))
buffer = INDEFS
else
buffer = ival
} else { # string
lenstr = -COL_DTYPE(cp) + 1 # one for EOS
ip = (rownum - 1) * lenstr + 1
if (ctol (Memc[COL_OFFSET(cp)], ip, lval) > 0) {
if (abs (lval) > MAX_SHORT)
buffer = INDEFS
else
buffer = lval
} else {
buffer = INDEFS
}
}
end
procedure tbzgtt (tp, cp, rownum, buffer, maxch)
pointer tp # i: pointer to table descriptor
pointer cp # i: pointer to column descriptor
int rownum # i: row number
char buffer[ARB] # o: buffer for value to be gotten
int maxch # i: size of buffer
#--
double dval # buffer for double precision
int ival # buffer for integer value
int lenstr # length of a string table element
int ip # offset for extracting a string in Memc
begin
if (COL_DTYPE(cp) == TBL_TY_DOUBLE) {
dval = Memd[COL_OFFSET(cp) + rownum - 1]
if (IS_INDEFD(dval)) {
call strcpy ("INDEF", buffer, maxch)
} else {
call sprintf (buffer, maxch, COL_FMT(cp))
call pargd (dval)
}
} else if (COL_DTYPE(cp) == TBL_TY_INT) {
ival = Memi[COL_OFFSET(cp) + rownum - 1]
if (IS_INDEFI(ival)) {
call strcpy ("INDEF", buffer, maxch)
} else {
call sprintf (buffer, maxch, COL_FMT(cp))
call pargi (ival)
}
} else { # string
lenstr = -COL_DTYPE(cp) + 1 # one for EOS
ip = (rownum - 1) * lenstr
call strcpy (Memc[COL_OFFSET(cp) + ip], buffer, maxch)
}
end
|