APP DESIGNER - How to try and catch TeX syntax?

9 visualizzazioni (ultimi 30 giorni)
Tor Hadas
Tor Hadas il 20 Apr 2016
Risposto: Roger Parkyn il 10 Giu 2019
I have a uiaxes component and an uieditfield component.
I want the user to be able to change the uiaxes' title using the edit field, in TeX syntax.
My problem is everytime I try to write a wrong TeX syntax string, an error pops out.
I want to be able to catch the error and display an error to the user if the syntax is wrong, instead of matlab going crazy.
This is my code:
try
title(app.MyAxes, app.MyEditField.Value);
catch
SetError(app, 'Invalid TeX syntax');
end
(SetError is a function I made to diplay errors to the user)
this does not work - instead I get this error:
Error using appdesigner.internal.appdesignererrorcallback (line 8)
Error updating Text.
String must have valid interpreter syntax:
MyWrongSyntaxTitle{
Error in appdesigner.internal.service.AppManagementService/axeserrorhandler (line 138)
appdesigner.internal.appdesignererrorcallback(event.Source, event);
Error in appdesigner.internal.service.AppManagementService>@(source,event)obj.axeserrorhandler(event,app) (line 132)
@(source, event)obj.axeserrorhandler(event, app);
Error while evaluating HTMLCanvas ErrorCallback
(MyWrongSyntaxTitle{ is the text I put in the edit field to test the try-catch)
What am I doing wrong? How can I catch this error?
(SetError is never called)

Risposte (1)

Roger Parkyn
Roger Parkyn il 10 Giu 2019
I don't know the answer to your specific quesion but this may help others using appdesigner:
try
some_code; % You can put it around quite large chunks of code so that, at least, it fails more informatively
catch ME % ME is of the class MException (in-built Matlab)
str = sprintf(['Something is wrong with the plotting code. \n' 'Matlab says: \n' ME.message]);
uialert(app.UIFigure, str, 'Plotting Problem');
end

Categorie

Scopri di più su Software Development Tools in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by