How to handle errors within a mask callback?
11 views (last 30 days)
I want to validate the mask input (edit fields) from the user using the parameter's callback.
How shall I report those invalid values (missing WS parameter, negative number when positive only, etc) ?
%paramName might reference a WS variable or be a numeric-string.
var = evalin(paramName, 'base')
test = (var >= 0);
I can use both
sldiagviewer.reportError(sprintf('... block %s ...', getfullname(containerHandle)));
error(... block %s ...' , getfullname(containerHandle));
This is troublesome when having a library block allowed to modify itself as the init_callback is executed twice, hence doubling the error message in the 'Diagnostic Viewer'.
Is there another way to gently output an error message within Simulink?
As a side question: is there a way to prevent the repeated execution of the initialization callback?
Sanman on 27 Jan 2022
If I understand correctly, you're looking to validate the mask parameter values. These could be done without introducing a parameter callback as well by using "Mask Parameter Constraints". If you do not necessarily want to use the parameter callback for validation, you can check out the following link to the doc page.
You can also refer to this documentation page for further reference.