can i call app designer CallBack Functions outside the app ?

6 visualizaciones (últimos 30 días)
Ibrahim Essam
Ibrahim Essam el 12 de Abr. de 2017
Comentada: Sarah Bell el 22 de Abr. de 2018
hello
i want to know if it is possible to call for example
buttonpushedcallback()
from an external .m script
so i want to process some data in my matlab script then i call callbacks functions
i tried this
a=myapp
a.buttonpushedcallback(a)
but it gave me error no class or public property called buttonpushedcallback in myapp

Respuestas (1)

Adam
Adam el 12 de Abr. de 2017
Editada: Adam el 12 de Abr. de 2017
Yes, it is possible, but you need to understand the basics of function scope.
a=myapp
a.buttonpushedcallback(a)
would be wrong in all contexts. You either put a. at the front or you pass a in as an argument, you don't do both because they amount to the same thing so you would be passing it in twice, as the first two arguments with this syntax.
You use
a.buttonpushedcallback( )
or
buttonpushedcallback( a )
if a is an object of a class and buttonpushedcallback is a method of that class. For a method that is not part of the class you just call
buttonpushedcallback( )
If you really want you can have a method that is external to the class that still takes an object of it as first argument:
buttonpushedcallback( a )
but you cannot use the a.buttonpushedcallback syntax here. Quite why you would want to do this I don't know, since if it takes the class object as argument it should be a method of the class in general, but it is possible.
For a callback though you generally need to pass in two arguments representing the source and event data though also for it to be recognised as a valid callback signature.
  5 comentarios
Adam
Adam el 20 de Abr. de 2018
That sounds like you just ave a syntax error somewhere above that in your code. Check for a missing 'end' from previous functions or method blocks. Selecting everything (e.g. Ctrl + A) and then auto-indenting with Ctr + I can help you to easily spot missing 'end' statements.
Sarah Bell
Sarah Bell el 22 de Abr. de 2018
Thank you so much! This just fixed my code, and now I can not only submit it 14+ hours early but I'm probably going to get the best mark I've ever had on any coding based coursework, so thank you again!
While I have you here, my boyfriend is also doing coding coursework and was wondering if you happen to know anything about the Kernighan-Lin (or KL) algorithm in Matlab?

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by