How to handle errors within a mask callback?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
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) ?
try
%paramName might reference a WS variable or be a numeric-string.
var = evalin(paramName, 'base')
test = (var >= 0);
catch ME
...
end
I can use both
sldiagviewer.reportError(sprintf('... block %s ...', getfullname(containerHandle)));
or
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?
0 commentaires
Réponses (1)
Sanman
le 27 Jan 2022
Hi Sylvain,
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.
https://www.mathworks.com/help/simulink/ug/mask-parameter-constraints.html
0 commentaires
Voir également
Catégories
En savoir plus sur Author Block Masks dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!