Adding another function in an "App Designer" function - matlab

I'm using App Designer in MATLAB. I have created a push button, 51-54 work no problem, then when I assigned another function into it (highlighted in the screenshot), it wouldn't work!
Please help me overcome this problem.
Screenshot showing the problem:

Problem: function inside of a function the way it is written in the screenshot.
4 things come up my mind:
Generally:
yourApp.mlapp or any other code.m file
function someProcess()
end
function subProcess()
end
In your case rather try to write your function in an second .m file and call it from within your your app.
be sure to have it on the MATLAB path.
yourApp.mlapp or any other code.m file
function someProcess()
subProcess();
end
+ external code.m file
function someProcess()
subProcess();
end
define your function as a public or private function (method) inside the app. ( for others: the block is not there by default. click: app designer> code view > function > add private function | add public function)
screenshot
if your function is only used once you could also write an anonymous function
https://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html

Related

FuelPHP \URI::current() does not get file extension

My project requires me to know what file extension was used while calling a route.
For example,
If the route was 127.0.0.1/controller/action/filea.json
Then then I would need to have a function that returns ".json" when called from inside action function "get_action".
If the route was 127.0.0.1/controller/action2/fileb.xml
Then then the function should return ".xml" when called from inside action function "get_action2".
Right now, I tried using \URI::current(), but that only gets me "127.0.0.1/controller/action/filea" or "127.0.0.1/controller/action2/fileb"
Whether or not the extension is used is controlled by the config key routing.strip_extension, which is true by default.
The current extension can be retrieved using \Input::extension().

Creating an instance of a class

Trying to create my first class in MATLAB but obviously am missing something.
So here is my class below.
classdef MyBank
properties
Balance;
CustName;
end
methods
function BA = MyBank()
BA.Balance = 0;
BA.CustName = 'Mr Blogs'
end
end
end
In the same path I have a m file. In this file I try to create an object from my class like so,
bank = MyBank;
I get the error message 'undefined function or variabel 'MyBank'? Not sure what I'm missing as the examples I have seen appear to do the same thing?
Also when typing BA in my constructor should there be any intellisense? Find it quite painful coding in Matlab.
Matlab doesn't understand ".
You shuold use BA.CustName = 'Mr Blogs'
Are you using Matlab or Octave? Octave understands ", but last time I checked classdef is not working.
To find the constructor with "intellisense", you should type "My" and then press tab. At least for me this works.
If this doesn't work for you, check that your file is named MyBank.m and double check if it is in your current working folder. Open the file in your edior window and execute it by pressing F5. Then a dialog should pop up, if your in another working directory.

Which file contains function of core/session in magento?

I need to customize other's code,
so I found they used
Mage::getSingleton('core/session')->getMyCustomBlockInfo();
in Order.php file for custom order email
so I can't find this function getMyCustomBlockInfo();
Can anyone tell me where this function reside?
Thanks
those are magic functions get() and set() and you are asking a session variable there that is set as
Mage::getSingleton('core/session')->setMyCustomBlockInfo();
somewhere in your code. If you use terminal you can easily find by making a following grep:
grep '>setMyCustomBlockInfo(' . -rsni
and it will list the files where your variable is set to session.
example :
Mage::getModel('catalog/product'); //or
Mage::getSingleton('catalog/product');
the code must be in '../app/core/Mage/Catalog/Model/Product.php' file
then
Mage::getSingleton('core/session');
the code must be in '../app/core/Mage/Core/Model/Session.php' file
because the class Mage_Core_Model_Session's parent::parent is Varien_Object, then you can do all magic functions and you can ->getData() to see the Data inside.
Mage::getSingleton('core/session')->getData();
on your problem when go call ->getData() you can see data : [my_custom_block_info]
you can set it with call
Mage::getSingleton('core/session')->setMyCustomBlockInfo('what');
Mage::getSingleton('core/session')->getMyCustomBlockInfo();
// will return 'what'

How to use the function in springboard server?

I want to use the function "Reboot()" in the app with the springboardserver.framework,But when i add the private framework and the headers of springboardserver, the error will appear.
the reboot() is in the springboardserver.framework,the info about the springboardserver.framework function.
http://iphonedevwiki.net/index.php/SpringBoard.app/MIG_subsystem
I want to know how to use the function like this.Thank you for your help.
there is a function called SBReboot() (not sure about the function arguments) in SpringBoardServices.framework

Lua Scripting Push Class Function PN.click()

I'm incorporating Lua scripting in my iPhone game implementation and it's working great!
For purely cosmetic reasons, I'd like for my functions in Lua to be in the format of PN.function(). Currently they are in the format of function().
I've tried registering the function as such:
lua_register(lua, "PN.Color", Color);
But it won't let me call it in the Lua script.
Anyone have any suggestions?
Thanks!
Answered my own question!:
lua_newtable(lua);
int pn = lua_gettop(lua);
lua_pushstring(lua, "Click");
lua_pushcfunction(lua, Click);
lua_settable(lua, pn);
lua_pushstring(lua, "Release");
lua_pushcfunction(lua, Release);
lua_settable(lua, pn);
lua_setglobal(lua, "PN");
You cannot use . as a function name in Lua. If you're trying to put all of your Lua functions in a global table called PN, then you have to actually do that.
Remember: lua_register is just a macro:
#define lua_register(L,n,f) \
(lua_pushcfunction(L, f), lua_setglobal(L, n))
There's nothing that say you couldn't do it yourself more specifically.
If you have a global table PN that you want to register Lua functions into, you do the following:
Push the PN table onto the stack, using lua_getfield(L, LUA_GLOBALSINDEX, "PN").
Push the function you want to register onto the stack, with lua_pushcfunction(L, Color).
Put the function into the proper location in the table, with lua_setfield(L, -2, "Color").
Pop the table from the stack with lua_pop(L, 1).