functions definitions

Dec 6, 2012 at 9:51 PM

 

hi Keith,

 

 what is the correct format ? lets say i have something like:

#define EXCEL12

static AddInX xai_test(

FunctionX(XLL_HANDLEX, _T("?xll_test"), _T("test.test"))

.Arg(XLL_FPX, _T("aaaaaaaaaa1"), _T("a1"))

....

.Category(CATEGORY) .FunctionHelp(_T("A function that does foo.")));

 

i can only go upto say about 15 or 16 arguments. meaning the function fails to register if i have more than about 16 arguments. when i change to something like 

Arg(XLL_FPX, _T("aaa1"), _T("a1"))

that is shorten the argument names then i can go up in the number of arguments to past 30 and the function still registers okay.

i thought the excel12 limits are suffcinetly high such that I should not be hitting limits with number of arguments around 35 or so (with big argument names like above). Most probably I am mixing excel and excel12 definitions ?

It would be kind of you to comment.

 

Coordinator
Dec 7, 2012 at 2:11 AM

Did you #define EXCEL12 before #include "xll/xll.h"?

If not, there are two limits. You can do up to 32 arguments, but the argument text is limited to 255 characters.

Excel 2007 and later does not have these limits, but you are doing it wrong if you are bumping into this. If you expect human beings to use the software you are producing, you should have some mercy on them. Factor your code down to smaller pieces and get with the Zen of Excel. It is great for glueing together small bite-sized pieces of functionality.

 

Dec 7, 2012 at 6:25 PM

i definitely have a #define EXCEL12 before #include "xll/xll.h". 

if i have .ARG() defined as Arg(XLL_FPX, _T("a01"), _T("a1")) i can go upto Arg(XLL_FPX, _T("a45"), _T("a45")) (this kind of demonstrates that i am above the excel 2003 limit). i start increasing the length of the argument by introducing another "a" and can i go up to Arg(XLL_FPX, _T("aa32"), _T("a32")) after which the addin fails to register. so i am hitting the excel 2003 limit.  

so somewhere within the xll library excel 2007 and excel 2003 definitions are mixed up. 

if interested i give below the simple block of code which kind of demonstrates the issue(i see the issue in excel 2007). the function below registers okay but when you increase the function argument with another "a" it will fail to register.

#define EXCEL12

#include "xll/xll.h"

static AddInX xai_test(

FunctionX(XLL_HANDLEX, _T("?xll_test"), _T("test.test")) 

.Arg(XLL_FPX, _T("aa01"), _T("a1")) .Arg(XLL_FPX, _T("aa02"), _T("a2")) .Arg(XLL_FPX, _T("aa03"), _T("a3")) .Arg(XLL_FPX, _T("aa04"), _T("a4")) .Arg(XLL_FPX, _T("aa05"), _T("a5")) .Arg(XLL_FPX, _T("aa06"), _T("a6")) .Arg(XLL_FPX, _T("aa07"), _T("a7")) .Arg(XLL_FPX, _T("aa08"), _T("a8")) .Arg(XLL_FPX, _T("aa09"), _T("a9")) .Arg(XLL_FPX, _T("aa10"), _T("a10")) .Arg(XLL_FPX, _T("aa11"), _T("a11")) .Arg(XLL_FPX, _T("aa12"), _T("a12")) .Arg(XLL_FPX, _T("aa13"), _T("a13")) .Arg(XLL_FPX, _T("aa14"), _T("a14")) .Arg(XLL_FPX, _T("aa15"), _T("a15")) .Arg(XLL_FPX, _T("aa16"), _T("a16")) .Arg(XLL_FPX, _T("aa17"), _T("a17")) .Arg(XLL_FPX, _T("aa18"), _T("a18")) .Arg(XLL_FPX, _T("aa19"), _T("a19")) .Arg(XLL_FPX, _T("aa20"), _T("a20")) .Arg(XLL_FPX, _T("aa21"), _T("a21")) .Arg(XLL_FPX, _T("aa22"), _T("a22")) .Arg(XLL_FPX, _T("aa23"), _T("a23")) .Arg(XLL_FPX, _T("aa24"), _T("a24")) .Arg(XLL_FPX, _T("aa25"), _T("a25")) .Arg(XLL_FPX, _T("aa26"), _T("a26")) .Arg(XLL_FPX, _T("aa27"), _T("a27")) .Arg(XLL_FPX, _T("aa28"), _T("a28")) .Arg(XLL_FPX, _T("aa29"), _T("a29")) .Arg(XLL_FPX, _T("aa30"), _T("a30")) .Arg(XLL_FPX, _T("aa31"), _T("a31")) .Arg(XLL_FPX, _T("aa32"), _T("a32")) .Arg(XLL_FPX, _T("a33"), _T("a33")) .Arg(XLL_FPX, _T("a34"), _T("a34")) .Arg(XLL_FPX, _T("a35"), _T("a35")) .Arg(XLL_FPX, _T("a36"), _T("a36")) .Arg(XLL_FPX, _T("a37"), _T("a37")) .Arg(XLL_FPX, _T("a38"), _T("a28")) .Arg(XLL_FPX, _T("a39"), _T("a29")) .Arg(XLL_FPX, _T("a40"), _T("a30")) .Arg(XLL_FPX, _T("a41"), _T("a31")) .Arg(XLL_FPX, _T("a42"), _T("a32")) .Arg(XLL_FPX, _T("a43"), _T("a33")) .Arg(XLL_FPX, _T("a44"), _T("a34")) .Arg(XLL_FPX, _T("a45"), _T("a35"))

 .Uncalced() .Category(_T("test")) .FunctionHelp(_T("creates test")));

HANDLEX WINAPI

xll_test( const _FPX* a01 ,const _FPX* a02 ,const _FPX* a03 ,const _FPX* a04 ,const _FPX* a05 ,const _FPX* a06 ,const _FPX* a07 ,const _FPX* a08 ,const _FPX* a09 ,const _FPX* a10 ,const _FPX* a11 ,const _FPX* a12 ,const _FPX* a13 ,const _FPX* a14 ,const _FPX* a15 ,const _FPX* a16 ,const _FPX* a17 ,const _FPX* a18 ,const _FPX* a19 ,const _FPX* a20 ,const _FPX* a21 ,const _FPX* a22 ,const _FPX* a23 ,const _FPX* a24 ,const _FPX* a25 ,const _FPX* a26 ,const _FPX* a27 ,const _FPX* a28 ,const _FPX* a29 ,const _FPX* a30 ,const _FPX* a31 ,const _FPX* a32 ,const _FPX* a33     ,const _FPX* a34     ,const _FPX* a35 ,const _FPX* a36     ,const _FPX* a37 ,const _FPX* a38 ,const _FPX* a39 ,const _FPX* a40 ,const _FPX* a41 ,const _FPX* a42 ,const _FPX* a43     ,const _FPX* a44     ,const _FPX* a45  )

{
#pragma XLLEXPORT

HANDLEX h(0);
return h;

}

Coordinator
Dec 7, 2012 at 6:48 PM

I am at a loss to think of a plausible example of a useful function taking even 16 arguments. Can you provide one?

Dec 7, 2012 at 6:52 PM

i am not sure how the addin works. but within the code (in file auto.cpp) i observe (when i am in the debug mode)

---------------------auto.cpp--------------------------

// auto.cpp - Implement well-known xlAutoXXX entry points required for xll's.// Copyright (c) 2011 KALX, LLC. All rights reserved. No warranty is made.#include "xll/xll.h"
using namespace xll;
extern "C" int WINAPIxlAutoOpen(void){ try { ensure (Auto<Open>::Call()); ensure (AddIn::RegisterAll()); ensure (Auto<OpenAfter>::Call());

-------------------------------------------------------------

it is trying to register an xloper

AddIn::RegisterAll = 0x000007fef3a4a030 xll::XAddIn<xloper>::RegisterAll(void) 

 

with #define EXCEL12  declared, i thought, it should be trying to register an xloper12. 

but i may be wrong. i am not an expert on this field as you are.

Dec 7, 2012 at 7:03 PM

the standard model in high energy physics has 19 paramters for its lagrangian. i may want to take in each parameter as a separate argument of a function. but that is besides the point. i was just trying the demonstrate that somewhere the addin is not working as i thought it should work. 

Coordinator
Dec 7, 2012 at 7:45 PM

Damn. There goes my high energy physics 19 parameter lagrangian market.

The xll library registers both AddIn and AddIn12 objects in Excel 2007 and above.

Dec 7, 2012 at 10:19 PM

hmm interesting. between excel 2003 and excel 2007 Microsoft thought functions with 30 arguments is not enough and went to 255 arguments and you think anything more than 16 is not that useful. there are big communities of researchers who does computer simulation that routinely takes several hours to compute (in the fastest computers) and you think any function that needs in_function_wizard() is too slow to be worth using. i guess these type of diversity of opinions makes the world so beautiful.  but i must also add the xll addin you developed is very nice.  

Coordinator
Dec 8, 2012 at 1:33 PM

Thanks for your kind words. The world is big, complicated and diverse, but people come in packages.

I've figured out why people want things. They want them because they want them.