|
From: | Amro |
Subject: | [Octave-bug-tracker] [bug #49793] octave's inputParser only accepts validation functions that return true or false |
Date: | Thu, 8 Dec 2016 16:19:28 +0000 (UTC) |
User-agent: | Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:45.9) Gecko/20100101 Goanna/3.0 Firefox/45.9 PaleMoon/27.0.2 |
Follow-up Comment #7, bug #49793 (project octave): @jwe if nargout doesn't work with builtins, then calling something like ip.addRequired('name',@isnumeric); will always fail in your solution because "nargout" will throw an error... I think we need to need to test the error in the catch block and attempt calling the validation function another time inside a second try/catch if the error indicated a too-many-output case. How about this version (it's sort of a hack until "nargout" is fixed): try nout = nargout(val); catch nout = -1; % val is a builtin function end result = true; try if nout ~= 0 result = val(in); else val(in); end catch ME if strcmp(ME.identifier, 'Octave:TooManyOutputs') try val(in); catch result = false; end else result = false; end end _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?49793> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |