Is there is way to access cell that contains my UDF?
I need to reset some cache when function with same parameters is run from different cell.
Didn't find anything suitable in exceldna utils.
Thanks,
Alex
You can call
ExcelReference caller = XlCall.Excel(XlCall.xlfCaller) as ExcelReference;
The result will be an ExcelReference if you're called from a sheet formula. It might be null if you're called via Application.Run or a few other ways.
ExcelReference is a wrapper for the C API sheet reference.
Related
When I create a function like this:
v8::Function::New(<Isolate>, <C_Function>, <Data_Value>);
The Data_Value that I supply is useful for many things and I can access that when the function is called, with something like FunctionCallbackInfo->GetData().
But I have found no way to get back this data in a different scenario. Let's say I store that Function in a Persistent object, and then I would like to read which data is currently bound to it. Any ideas?
I don't think it's exposed via the API.
But there's an alternative:
manually construct a v8::FunctionTemplate
set its ->InstanceTemplate()->SetInternalFieldCount(num_fields)
get the v8::Function from the template with template->GetFunction(context),
now you should have function->InternalFieldCount() == num_fields
you can use function->SetInternalField(index, value) and function->GetInternalField(index) to store any data you want.
For complete examples, search for "SetInternalFieldCount" in V8's test-api.cc.
I'm looking for a function that would tell me the current object and method by way of the URI. Normally, I would use $this->uri->uri_string(), however, I do not want to pass any "dynamic" segments. For example, a URI of 'products/shoes/123', would be 'products/view_product'.
I want to be able to do this so I can create a config file containing page titles... since I use a model to output my page header. It is called from MY_Controller.php in the construct. For example: $this->template->overall_header($title = "View Product")...
but in the construct, it would be:
$this->template->overall_header($title = $this->config->item($object_method_string));
Anybody have any solutions? Thanks for your time.
for current method
$method= $this->router->fetch_method();
I hope you are talking about this
To expand on Nishant's answer you can access the attributes from the router class.
So for current object;
$this->router->class
And for current method;
$this->router->method
I'm trying to use EasyHook in C# to properly hook into a method from a COM object (unmanaged).
I was able to determine the address of the method of the COM object and I can properly trigger my hook function. I did it this way, being the rest of the code pretty much similar to the one in the tutorial:
SendHook = LocalHook.Create(0x12345678, new DMyFunc(MyFunc_Hooked), this);
However, once inside my hook, all parameters are scrambled (they do not equal those that I'm originally passing).
Also, I'm not able to return anything (please note that I also tried hooking another function that returns a short and the value doesn't properly return).
When I open eXescope, this is one of the function signatures:
function MyFunc(out ParamA:^BSTR; out ParamB:^bool): ^TypeA;
And this function has the following signature when I use the COM object normally in C#:
TypeA MyFunc(ref string ParamA, ref bool ParamB);
Any ideas? Thanks in advance!
I managed to solve the problem in 5 minutes after reading the article provided by Dark Falcon. I totally recommend reading it! Therefore, all credit for the answer goes to him!
I'm trying to use the IShellFolder2.GetDefaultColumn function to get the default sort column that is recommended for a specific shell folder. But unfortunately, the function always fails with E_NOTIMPL (HResult -2147467263).
The method call looks like this:
hr := ishellfolder2.GetDefaultColumn(0, sortColumn, displayColumn);
The IShellFolder object is queried by using
SHBindToParent
or
ShellFolder.BindToObject
afterwards it's casted to an IShellFolder2.
The object is valid because it's successfully used for e.g. querying GetDetailsOf.
Is there anything I`m missing?
Thank you and best regards
Answer from Microsoft:
The reason why IShellFolder2.GetDefaultColumn always returns E_NOTIMPL is following:
Almost no shell folder implements this method. This means that this folder does not want to overwrite the defaut sort order. If this method succeeds, it returns a custom sort column that differs from the default sort column.
I have this line of code:
delete_btn = uicontrol(rr_ops, 'Style', 'pushbutton', 'String', 'Delete Graphic', 'Position', [13 135 98 20], ...
'Callback', 'delete_graphic');
and a little bit upper this function:
function delete_graphic
global rr_list
selected = get(rr_list, 'Value');
selected
return;
why this code is not working? I really dont understand...
What do I need? I create one button and a listbox, clicking on button - deleting selected element from a listbox.
Thx for help.
PS
Always getting this error:
??? Undefined function or variable 'delete_graphic'.
??? Error while evaluating uicontrol Callback
here is all my code: http://paste.ubuntu.com/540094/ (line 185)
The generally-preferred way to define a callback function is to use a function handle instead of a string. When you use a string, the code in the string is evaluated in the base workspace. This means that all the variables and functions used in the string have to exist in the base workspace when the callback is evaluated. This makes for a poor GUI design, since you don't really want the operation of your GUI dependent on the base workspace (which the user can modify easily, thus potentially breaking your GUI).
This also explains the error you are getting. The function delete_graphic is defined as a subfunction in your file rr_intervals.m. Subfunctions can only be called by other functions defined in the same m-file, so delete_graphic is not visible in the base workspace (where your string callback is evaluated). Using a function handle callback is a better alternative. Here's how you would do it:
Change the callback of your button (line 216) from 'delete_graphic' to #delete_graphic.
Change the function definition of delete_graphic (line 185) to:
function delete_graphic(hObject,eventdata)
where hObject is the handle of the object issuing the callback and eventdata is optional data provided when the callback is issued.
EDIT:
If you want to pass other arguments to delete_graphic, you can perform the following steps:
Add the additional input arguments to the end of the function definition. For example:
function delete_graphic(hObject,eventdata,argA,argB)
Use a cell array when you set the callback for your button, where the first cell contains the function handle and the subsequent cells each contain an input argument. For example:
set(delete_btn,'Callback',{#delete_graphic,A,B});
There is one caveat to this, which is that the values A and B stored in the cell array are fixed at what they are when you set the callback. If you change A or B in your code it will not change the values stored in the cell-array callback.
If you aren't able to use the above solution (i.e. if A and B need to change value), there are a few other options for how you can share data among a GUI's callbacks:
You can rework the organization of your code to make use of nested functions. This makes it very easy to share data between callbacks. Some nice examples of using nested functions to create GUIs can be found in the MathWorks File Exchange submission GUI Examples using Nested Functions by Steven Lord.
You can store data in the UserData property of a uicontrol object. To access or update it, you just need the object handle.
You can use the functions SETAPPDATA/GETAPPDATA to attach data to a handle graphics object (i.e. uicontrol).
Since it appears your code was created using GUIDE, you can make use of the handles structure GUIDE creates to store data using the GUIDATA function.