comparison src/variables.cc @ 3178:09a3064a3a17

[project @ 1998-06-23 03:46:42 by jwe]
author jwe
date Tue, 23 Jun 1998 03:47:31 +0000
parents e4bbfc196e53
children 041ea33fbbf4
comparison
equal deleted inserted replaced
3177:d81db29f8b2b 3178:09a3064a3a17
132 } 132 }
133 133
134 // Is this octave_value a valid function? 134 // Is this octave_value a valid function?
135 135
136 octave_function * 136 octave_function *
137 is_valid_function (const octave_value& arg, const string& warn_for, bool warn) 137 is_valid_function (const string& fcn_name, const string& warn_for, bool warn)
138 { 138 {
139 octave_function *ans = 0; 139 octave_function *ans = 0;
140
141 string fcn_name;
142
143 if (arg.is_string ())
144 fcn_name = arg.string_value ();
145
146 if (fcn_name.empty () || error_state)
147 {
148 if (warn)
149 error ("%s: expecting function name as argument",
150 warn_for.c_str ());
151 return ans;
152 }
153 140
154 symbol_record *sr = 0; 141 symbol_record *sr = 0;
155 142
156 if (! fcn_name.empty ()) 143 if (! fcn_name.empty ())
157 sr = lookup_by_name (fcn_name); 144 sr = lookup_by_name (fcn_name);
167 if (warn) 154 if (warn)
168 error ("%s: the symbol `%s' is not valid as a function", 155 error ("%s: the symbol `%s' is not valid as a function",
169 warn_for.c_str (), fcn_name.c_str ()); 156 warn_for.c_str (), fcn_name.c_str ());
170 ans = 0; 157 ans = 0;
171 } 158 }
159
160 return ans;
161 }
162
163 octave_function *
164 is_valid_function (const octave_value& arg, const string& warn_for, bool warn)
165 {
166 octave_function *ans = 0;
167
168 string fcn_name;
169
170 if (arg.is_string ())
171 fcn_name = arg.string_value ();
172
173 if (! error_state)
174 ans = is_valid_function (fcn_name, warn_for, warn);
175 else if (warn)
176 error ("%s: expecting function name as argument", warn_for.c_str ());
172 177
173 return ans; 178 return ans;
174 } 179 }
175 180
176 octave_function * 181 octave_function *