Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.sdk,microsoft.public.excel.programming
external usenet poster
 
Posts: 837
Default How Many Arguments?

Is it possible in a C based .xll function that takes a variable number
of arguments, to determine how many arguments were actually given?

In VBA

Function NumArgs(ParamArray Args() As Variant) As Integer
NumArgs = UBound(Args()) + 1
End Function

does the trick.

In the FuncSum example function from the SDK's Generic.c I do not see a
corresponding approach. I could loop through px1 through px29 and
determine which ones do not have xltypeMissing; but that would not
distinguish between =FuncSum() and
=FuncSum(,,,,,,,,,,,,,,,,,,,,,,,,,,,,), where in one case no arguments
were given and in the other 29 missing arguments were given.

Also, is it possible to either program or register FuncSum in such a way
that at least one argument must be given before Excel will call the
function? For example the worksheet function SUM produces an error
dialog if you attempt to enter =SUM(); you must give SUM at least one
argument, even if that argument is missing.

I know that it is not possible to exactly reproduce all behavior of
native Excel functions in user defined functions (either VBA or .xll).
For example Excel 3-D references cannot be passed to either type of UDF
(though some have kludged alternative structures to preserve the
functionality). Are these more examples of incompletely supported features?

Jerry

  #2   Report Post  
Posted to microsoft.public.excel.sdk,microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How Many Arguments?

I thought FuncSum() and FuncSum(,,,,,,,,,,,,,,,,,,,,,,,,,,,,) were the
same, and I would loop through the XLMissings to find the number of
arguments.
For the first argument you could throw an error if it is XLMissing, for the
others XLMissing would be whatever default you wish.
3D references don't seem to really exist in Excel, where they do they have
been kludged (eg Excels SUM() function) , and I don't know how they did it.


"Jerry W. Lewis" wrote in message
...
Is it possible in a C based .xll function that takes a variable number
of arguments, to determine how many arguments were actually given?

In VBA

Function NumArgs(ParamArray Args() As Variant) As Integer
NumArgs = UBound(Args()) + 1
End Function

does the trick.

In the FuncSum example function from the SDK's Generic.c I do not see a
corresponding approach. I could loop through px1 through px29 and
determine which ones do not have xltypeMissing; but that would not
distinguish between =FuncSum() and
=FuncSum(,,,,,,,,,,,,,,,,,,,,,,,,,,,,), where in one case no arguments
were given and in the other 29 missing arguments were given.

Also, is it possible to either program or register FuncSum in such a way
that at least one argument must be given before Excel will call the
function? For example the worksheet function SUM produces an error
dialog if you attempt to enter =SUM(); you must give SUM at least one
argument, even if that argument is missing.

I know that it is not possible to exactly reproduce all behavior of
native Excel functions in user defined functions (either VBA or .xll).
For example Excel 3-D references cannot be passed to either type of UDF
(though some have kludged alternative structures to preserve the
functionality). Are these more examples of incompletely supported

features?

Jerry



  #3   Report Post  
Posted to microsoft.public.excel.sdk,microsoft.public.excel.programming
external usenet poster
 
Posts: 837
Default How Many Arguments?

Yes, there is no difference between FuncSum() and
FuncSum(,,,,,,,,,,,,,,,,,,,,,,,,,,,,) as coded in Generic.c; that is
what I want code to cange.

Unlike FuncSum(), native Excel functions that take an arbitrary number
of arguments, treat explicitly passed missing values as zero. Thus
AVERAGE(1)=1 but AVERAGE(1,)=0.5; COUNT(,,,,,,,,,,,,,,,,,,,,,,,,,,,,)=29
COUNT(,)=2, and if it were permitted, COUNT() would equal zero. That
is what I want to be able to do in .xll functions; emulate as exactly as
possible the argument processing of native Excel functions, but with
better numerical accuracy.

Jerry

John Drummond wrote:

I thought FuncSum() and FuncSum(,,,,,,,,,,,,,,,,,,,,,,,,,,,,) were the
same, and I would loop through the XLMissings to find the number of
arguments.
For the first argument you could throw an error if it is XLMissing, for the
others XLMissing would be whatever default you wish.
3D references don't seem to really exist in Excel, where they do they have
been kludged (eg Excels SUM() function) , and I don't know how they did it.


"Jerry W. Lewis" wrote in message
...

Is it possible in a C based .xll function that takes a variable number
of arguments, to determine how many arguments were actually given?

In VBA

Function NumArgs(ParamArray Args() As Variant) As Integer
NumArgs = UBound(Args()) + 1
End Function

does the trick.

In the FuncSum example function from the SDK's Generic.c I do not see a
corresponding approach. I could loop through px1 through px29 and
determine which ones do not have xltypeMissing; but that would not
distinguish between =FuncSum() and
=FuncSum(,,,,,,,,,,,,,,,,,,,,,,,,,,,,), where in one case no arguments
were given and in the other 29 missing arguments were given.

Also, is it possible to either program or register FuncSum in such a way
that at least one argument must be given before Excel will call the
function? For example the worksheet function SUM produces an error
dialog if you attempt to enter =SUM(); you must give SUM at least one
argument, even if that argument is missing.

I know that it is not possible to exactly reproduce all behavior of
native Excel functions in user defined functions (either VBA or .xll).
For example Excel 3-D references cannot be passed to either type of UDF
(though some have kludged alternative structures to preserve the
functionality). Are these more examples of incompletely supported

features?

Jerry





  #4   Report Post  
Posted to microsoft.public.excel.sdk,microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How Many Arguments?

Good point.
It seems that MS functions have genuinely variable-length argument lists (I
guess that's why there's no limit to the number of args to a SUM()), whereas
SDK functions only have optional variables, which are not the same thing.
On 3D ranges, I see that the freeware add-in MoreFunc.xll does employ 3D
ranges in a couple of its functions, so 3D might actually be possible in the
SDK. Don't know how though.
Good luck

John

"Jerry W. Lewis" wrote in message
...
Yes, there is no difference between FuncSum() and
FuncSum(,,,,,,,,,,,,,,,,,,,,,,,,,,,,) as coded in Generic.c; that is
what I want code to cange.

Unlike FuncSum(), native Excel functions that take an arbitrary number
of arguments, treat explicitly passed missing values as zero. Thus
AVERAGE(1)=1 but AVERAGE(1,)=0.5; COUNT(,,,,,,,,,,,,,,,,,,,,,,,,,,,,)=29
COUNT(,)=2, and if it were permitted, COUNT() would equal zero. That
is what I want to be able to do in .xll functions; emulate as exactly as
possible the argument processing of native Excel functions, but with
better numerical accuracy.

Jerry

John Drummond wrote:

I thought FuncSum() and FuncSum(,,,,,,,,,,,,,,,,,,,,,,,,,,,,) were the
same, and I would loop through the XLMissings to find the number of
arguments.
For the first argument you could throw an error if it is XLMissing, for

the
others XLMissing would be whatever default you wish.
3D references don't seem to really exist in Excel, where they do they

have
been kludged (eg Excels SUM() function) , and I don't know how they did

it.


"Jerry W. Lewis" wrote in message
...

Is it possible in a C based .xll function that takes a variable number
of arguments, to determine how many arguments were actually given?

In VBA

Function NumArgs(ParamArray Args() As Variant) As Integer
NumArgs = UBound(Args()) + 1
End Function

does the trick.

In the FuncSum example function from the SDK's Generic.c I do not see a
corresponding approach. I could loop through px1 through px29 and
determine which ones do not have xltypeMissing; but that would not
distinguish between =FuncSum() and
=FuncSum(,,,,,,,,,,,,,,,,,,,,,,,,,,,,), where in one case no arguments
were given and in the other 29 missing arguments were given.

Also, is it possible to either program or register FuncSum in such a way
that at least one argument must be given before Excel will call the
function? For example the worksheet function SUM produces an error
dialog if you attempt to enter =SUM(); you must give SUM at least one
argument, even if that argument is missing.

I know that it is not possible to exactly reproduce all behavior of
native Excel functions in user defined functions (either VBA or .xll).
For example Excel 3-D references cannot be passed to either type of UDF
(though some have kludged alternative structures to preserve the
functionality). Are these more examples of incompletely supported

features?

Jerry







  #5   Report Post  
Posted to microsoft.public.excel.sdk,microsoft.public.excel.programming
external usenet poster
 
Posts: 837
Default How Many Arguments?

Actually, MoreFunc.xll does not do Excel 3-D references, it achieves the
same results through a different calling syntax.

http://longre.free.fr/downloads/Morefunc.exe
http://groups.google.com/groups?selm...B%40wanadoo.fr

Jerry

John Drummond wrote:

Good point.
It seems that MS functions have genuinely variable-length argument lists (I
guess that's why there's no limit to the number of args to a SUM()), whereas
SDK functions only have optional variables, which are not the same thing.
On 3D ranges, I see that the freeware add-in MoreFunc.xll does employ 3D
ranges in a couple of its functions, so 3D might actually be possible in the
SDK. Don't know how though.
Good luck

John

"Jerry W. Lewis" wrote in message
...

Yes, there is no difference between FuncSum() and
FuncSum(,,,,,,,,,,,,,,,,,,,,,,,,,,,,) as coded in Generic.c; that is
what I want code to cange.

Unlike FuncSum(), native Excel functions that take an arbitrary number
of arguments, treat explicitly passed missing values as zero. Thus
AVERAGE(1)=1 but AVERAGE(1,)=0.5; COUNT(,,,,,,,,,,,,,,,,,,,,,,,,,,,,)=29
COUNT(,)=2, and if it were permitted, COUNT() would equal zero. That
is what I want to be able to do in .xll functions; emulate as exactly as
possible the argument processing of native Excel functions, but with
better numerical accuracy.

Jerry

John Drummond wrote:


I thought FuncSum() and FuncSum(,,,,,,,,,,,,,,,,,,,,,,,,,,,,) were the
same, and I would loop through the XLMissings to find the number of
arguments.
For the first argument you could throw an error if it is XLMissing, for

the

others XLMissing would be whatever default you wish.
3D references don't seem to really exist in Excel, where they do they

have

been kludged (eg Excels SUM() function) , and I don't know how they did

it.


"Jerry W. Lewis" wrote in message
...


Is it possible in a C based .xll function that takes a variable number
of arguments, to determine how many arguments were actually given?

In VBA

Function NumArgs(ParamArray Args() As Variant) As Integer
NumArgs = UBound(Args()) + 1
End Function

does the trick.

In the FuncSum example function from the SDK's Generic.c I do not see a
corresponding approach. I could loop through px1 through px29 and
determine which ones do not have xltypeMissing; but that would not
distinguish between =FuncSum() and
=FuncSum(,,,,,,,,,,,,,,,,,,,,,,,,,,,,), where in one case no arguments
were given and in the other 29 missing arguments were given.

Also, is it possible to either program or register FuncSum in such a way
that at least one argument must be given before Excel will call the
function? For example the worksheet function SUM produces an error
dialog if you attempt to enter =SUM(); you must give SUM at least one
argument, even if that argument is missing.

I know that it is not possible to exactly reproduce all behavior of
native Excel functions in user defined functions (either VBA or .xll).
For example Excel 3-D references cannot be passed to either type of UDF
(though some have kludged alternative structures to preserve the
functionality). Are these more examples of incompletely supported


features?


Jerry







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF - more than seven arguments Hannah Excel Worksheet Functions 2 March 25th 10 09:21 AM
IF-more than 7 arguments Carolina Excel Discussion (Misc queries) 3 May 20th 08 10:38 PM
IF-more than 7 arguments in Carolina Excel Worksheet Functions 2 May 20th 08 08:46 PM
And, if, arguments.... Chuck_in_Mo Excel Worksheet Functions 19 February 12th 07 03:42 PM
arguments gemini0662 Excel Discussion (Misc queries) 9 July 13th 06 03:48 PM


All times are GMT +1. The time now is 07:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"