aboutsummaryrefslogtreecommitdiff
path: root/noao/twodspec/apextract/appars.x
blob: 8f68c0c9d8b09d492c10166b5d5a1d1704d411ed (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
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
include <math/iminterp.h>

procedure apopset (pset)

char	pset[ARB]		# Pset name
pointer	pp, clopset ()
common	/apparam/ pp

begin
	pp = clopset (pset)
end


procedure apcpset ()

pointer	pp
common	/apparam/ pp

begin
	call clcpset (pp)
end


procedure apgstr (param, str, maxchar)

char	param[ARB]		# Parameter name
char	str[ARB]		# String to return
int	maxchar			# Maximum length of string

pointer	pp
common	/apparam/ pp

begin
	call clgpset (pp, param, str, maxchar)
end


bool procedure apgetb (param)

char	param[ARB]		# Parameter name
bool	clgpsetb()
pointer	pp
common	/apparam/ pp

begin
	return (clgpsetb (pp, param))
end


int procedure apgeti (param)

char	param[ARB]		# Parameter name
int	clgpseti()
pointer	pp
common	/apparam/ pp

begin
	return (clgpseti (pp, param))
end


real procedure apgetr (param)

char	param[ARB]		# Parameter name
real	clgpsetr()
pointer	pp
common	/apparam/ pp

begin
	return (clgpsetr (pp, param))
end


real procedure apgimr (param, im)

char	param[ARB]		# Parameter name
pointer	im			# IMIO pointer
int	i, ctor()
pointer	pp, sp, str
real	rval, imgetr()
common	/apparam/ pp
errchk	imgetr

begin
	call smark (sp)
	call salloc (str, SZ_FNAME, TY_CHAR)
	call clgpset (pp, param, Memc[str], SZ_FNAME)
	i = 1
	if (ctor (Mems[str], i, rval) == 0)
	    rval = imgetr (im, Memc[str])
	call sfree (sp)
	return (rval)
end


int procedure apgwrd (param, keyword, maxchar, dictionary)

char	param[ARB]		# CL parameter string
char	keyword[ARB]		# String matched in dictionary
int	maxchar			# Maximum size of str
char	dictionary[ARB]		# Dictionary string

int	i, strdic()
pointer	pp
common	/apparam/ pp

begin
	call clgpset (pp, param, keyword, maxchar)
	i = strdic (keyword, keyword, maxchar, dictionary)
	if (i <= 0)
	    call error (1, "Ambiguous or unknown parameter value")
	return (i)
end


# APGINTERP -- Select an interpolator from a CL input string.  The procedure
# is coded to be protected from changes in the values of the interpolator
# types in interpdef.h.

int procedure apginterp (param)

char	param[ARB]		# CL parameter prompt string
int	index, iicodes[5]
pointer	sp, word
int	apgwrd()
errchk	apgwrd
data	iicodes /II_NEAREST, II_LINEAR, II_POLY3, II_POLY5, II_SPLINE3/

pointer	pp
common	/apparam/ pp

begin
	call smark (sp)
	call salloc (word, SZ_FNAME, TY_CHAR)

	index = max (1, min (5, apgwrd (param, Memc[word], SZ_FNAME,
	    "|nearest|linear|poly3|poly5|spline3|")))

	call sfree (sp)
	return (iicodes[index])
end


procedure appstr (param, str)

char	param[ARB]		# Parameter name
char	str[ARB]		# String to be put
pointer	pp, sp, str1, str2
common	/apparam/ pp

int	i, strmatch(), stridxs()

begin
	if (strmatch (param, "p_") == 0) {
	    call smark (sp)
	    call salloc (str1, SZ_FNAME, TY_CHAR)
	    call salloc (str2, SZ_LINE, TY_CHAR)
	    call sprintf (Memc[str1], SZ_FNAME, "%s.p_prompt")
		call pargstr (param)
	    call clgpset (pp, Memc[str1], Memc[str2], SZ_LINE)
	    if (Memc[str2] == '>') {
		i = stridxs (" \\\t\n", Memc[str2])
		if (i > 0)
		    Memc[str2+i-1] = EOS
		call clpstr (Memc[str2+1], str)
	    } else
		call clppset (pp, param, str)
	    call sfree (sp)
	} else
	    call clppset (pp, param, str)
end


procedure apputb (param, bval)

char	param[ARB]		# Parameter name
bool	bval			# Value to be put
pointer	pp, sp, str1, str2
common	/apparam/ pp

int	i, strmatch(), stridxs()

begin
	if (strmatch (param, "p_") == 0) {
	    call smark (sp)
	    call salloc (str1, SZ_FNAME, TY_CHAR)
	    call salloc (str2, SZ_LINE, TY_CHAR)
	    call sprintf (Memc[str1], SZ_FNAME, "%s.p_prompt")
		call pargstr (param)
	    call clgpset (pp, Memc[str1], Memc[str2], SZ_LINE)
	    if (Memc[str2] == '>') {
		i = stridxs (" \\\t\n", Memc[str2])
		if (i > 0)
		    Memc[str2+i-1] = EOS
		call clputb (Memc[str2+1], bval)
	    } else
		call clppsetb (pp, param, bval)
	    call sfree (sp)
	} else
	    call clppsetb (pp, param, bval)
end


procedure apputi (param, ival)

char	param[ARB]		# Parameter name
int	ival			# Value to be put
pointer	pp, sp, str1, str2
common	/apparam/ pp

int	i, strmatch(), stridxs()

begin
	if (strmatch (param, "p_") == 0) {
	    call smark (sp)
	    call salloc (str1, SZ_FNAME, TY_CHAR)
	    call salloc (str2, SZ_LINE, TY_CHAR)
	    call sprintf (Memc[str1], SZ_FNAME, "%s.p_prompt")
		call pargstr (param)
	    call clgpset (pp, Memc[str1], Memc[str2], SZ_LINE)
	    if (Memc[str2] == '>') {
		i = stridxs (" \\\t\n", Memc[str2])
		if (i > 0)
		    Memc[str2+i-1] = EOS
		call clputi (Memc[str2+1], ival)
	    } else
		call clppseti (pp, param, ival)
	    call sfree (sp)
	} else
	    call clppseti (pp, param, ival)
end


procedure apputr (param, rval)

char	param[ARB]		# Parameter name
real	rval			# Value to be put
pointer	pp, sp, str1, str2
common	/apparam/ pp

int	i, strmatch(), stridxs()

begin
	if (strmatch (param, "p_") == 0) {
	    call smark (sp)
	    call salloc (str1, SZ_FNAME, TY_CHAR)
	    call salloc (str2, SZ_LINE, TY_CHAR)
	    call sprintf (Memc[str1], SZ_FNAME, "%s.p_prompt")
		call pargstr (param)
	    call clgpset (pp, Memc[str1], Memc[str2], SZ_LINE)
	    if (Memc[str2] == '>') {
		i = stridxs (" \\\t\n", Memc[str2])
		if (i > 0)
		    Memc[str2+i-1] = EOS
		call clputr (Memc[str2+1], rval)
	    } else
		call clppsetr (pp, param, rval)
	    call sfree (sp)
	} else
	    call clppsetr (pp, param, rval)
end