Issue 10798 - Parameter passing / SUMIF doesn't accept same type
Summary: Parameter passing / SUMIF doesn't accept same type
Status: CLOSED DUPLICATE of issue 65866
Alias: None
Product: Calc
Classification: Application
Component: code (show other issues)
Version: OOo 1.0.1
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: ooo
QA Contact: issues@sc
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-20 15:57 UTC by mortoray
Modified: 2013-08-07 15:12 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description mortoray 2003-01-20 15:57:29 UTC
I don't know if this is a problem with the StarBasic parameter values or the SUMIF function.  If you have either of the following two Macro functions (StarBasic), and I tested both to check for conversion problems:

Function PassThru( Val As Object )
	PassThru = Val
End Function

Function PassThru( Val As Variant )
	PassThru = Val
End Function

And then create two SUMIF statements, such as:
=SUMIF( D2:D10; "EUR"; C2:C10 )
=SUMIF( PASSTHRU(D2:D10); "EUR"; C2:C10 )

The first statement should work as normal, but the second statement, with the call to passthru produces an "Err:504", yet the PassThru function should not have changed the type of the object.

This makes it impossible for a StarBasic macro to interact with the SUMIF function in a transparent manner -- that is, in the same way it interacts with the other functions such as SUM.
Comment 1 frank 2003-08-11 15:13:21 UTC
This is not a bug of the Basic.

VAL is a function and therefore could not be used as a variable.

So this is invalid.

Frank
Comment 2 frank 2003-08-11 15:16:44 UTC
sorry reopening as this seems to be nonsens.
Comment 3 frank 2003-08-11 15:17:52 UTC
seems to be a scripting problem. So I set the flags and reassign it.
Comment 4 kay.ramme 2003-08-14 13:29:49 UTC
Andreas, please have a look at this and target accordingly.
Comment 5 ab 2003-09-01 13:30:14 UTC
-> OOo 2.0
Comment 6 christof.pintaske 2004-06-17 16:40:43 UTC
cp: retargeted to Office-Later due to limited ressources
Comment 7 ab 2005-07-29 11:54:26 UTC
fst is right, VAL should not be used. But also with

Function PassThru( aVal As Variant )
	PassThru = aVal
End Function

I get the "Err:504".

-> nn:
aVal contains a SbxDimArray with lbound = 1 and ubound = 9
(by the way: accessing the array elements fails for some reason).
I could not detect any error situation in Basic when executing the
function PassThru and SbMethod::Call() also returns no error.
So I don't know where "Err:504" comes from. Please have a look.
Comment 8 niklas.nebel 2005-08-26 16:25:26 UTC
The Basic function works without problems and returns an array.
But SUMIF (and similar functions) accepts a cell range only, not an array-type
intermediate result. This is a limitation that might be changed at a later time,
but it works as described (the help specifies "cell range"), so it's not a defect.
Comment 9 ooo 2005-08-30 11:40:38 UTC
Accepting issue. In general, most functions that work on a cell range should
also accept an intermediate array as parameter, except a few that need cell
positions or database ranges.
Comment 10 mortoray 2005-08-31 14:16:00 UTC
I agree with the comments made, but the original defect I reported still exists.

The problem is *NOT* that SUMIF does not take an array (though that may well in
itself be another issue).  The problem is that the PassThru function is changing
the type of variable.

If SUMIF on D2:D10 works, that means D2:D10 is a CellRange as is explained that
SUMIF works only on CellRange.

Then, PassThru takes a Variant, so in this case we should be expecting an Object
(of type CellRange).

Then we simply return that type, and SUMIF should use it happily since we have
*not* modified the type.  Yet, it fails, since somewhere in the chain the
CellRange was converted to an array, yet it was not the StarBasic code that did it.

This is the defect I wanted to report, SUMIF was just an example to demonstrate
the error.
Comment 11 ooo 2005-09-01 11:51:31 UTC
Mortoray,

StarBASIC spreadsheet functions always receive arguments per value, in case of a
cell range as an array of copies of cell values. It is not a CellRange object,
and returned in your case is an array. The problem *IS* that SUMIF does not take
an array.

  Eike
Comment 12 ooo 2007-10-12 16:40:06 UTC
Setting duplicate to an issue that is more concise and to the point.

*** This issue has been marked as a duplicate of 65866 ***
Comment 13 ooo 2007-10-12 16:40:52 UTC
Closing dup.