How to fake an app handle in the arguments?

5 visualizaciones (últimos 30 días)
Adrian
Adrian el 5 de Oct. de 2022
Comentada: Adrian el 6 de Oct. de 2022
Hello.
I am working on a project which involves an app. What I do is to give the submethods a handle to the app, so that they can use the apps getter and setter methods, as well as the log file. This is done via Argument Validation, aka:
function [] = myFun(I, app, opt)
arguments
I (:, :) uint8 % the image
app (1, 1) eva
% Handle back to the app, to transfer data
opt.whatever1 (1, 1) {mustBeNumeric} = 100
opt.whatever2 (1, 1) {mustBeNumeric} = 100
opt.debug (1, 1) logical = false
end
% Function code
end
Now what I would like to do, is to be able to call the function like myFun(I, ?, 'debug', true), where I use the debug flag to not go into the parts of the code which actually uses the app handle. This would allow me to call the methods in the command line and not just from inside the app. In this case the '?' stands for whatever can be used. Empty strings or arrays do not work. Naively I'd use something like a Nullpointer, but I don't know if something like that exists in Matlab.
Any ideas or insights would be chuffing tremendous. Or if you know that this won't work as intended, that'd be good to know as well.

Respuesta aceptada

dpb
dpb el 5 de Oct. de 2022
Use mustBeScalarOrEmpty validation function instead of fixed size would get past that hurdle. I've no klew whether it'll actually work as intended or not, I've never used any of the argument validation stuff...
  1 comentario
Adrian
Adrian el 6 de Oct. de 2022
This seems to work.
Additionally I can set
opt.debug (1, 1) logical = isempty(app);
which immediately sets the debug flag as intended.
Thank you very much.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by