https://bugs.freedesktop.org/show_bug.cgi?id=66717

          Priority: medium
            Bug ID: 66717
          Assignee: [email protected]
           Summary: Allow use scalar User-defined Functions with range
                    arguments, similar to built-in functions
          Severity: enhancement
    Classification: Unclassified
                OS: All
          Reporter: [email protected]
          Hardware: Other
            Status: UNCONFIRMED
           Version: 3.6.3.2 release
         Component: BASIC
           Product: LibreOffice

I want to create a User Defined Function
(https://help.libreoffice.org/Calc/User-Defined_Functions) for use in Calc. It
is intended to take a numeric value as argument. But I need it to work like
built-in functions like "SQRT" do: if you pass a range to it, it selects one
value from that range that corresponds to either same column or same row as the
calling cell (the cell in which the function is calculated). You may, for
example, set A1 = 1, A2 = 4, A3 = 9, and if you put "=SQRT($A$1:$A$3)" into B1,
B2 and B3, you will see B1 = 1, B2 = 2, and B3 = 3. But if I declare a function
in LibreOffice Basic like this:

function Func(x)
 Func = x^2
end function

and use it in a cell (say, C1) like "=Func($A$1:$A$3)", it will bring error,
because x is array, not single value. And there seems to be no way to tell Calc
to pass the arguments like it does to built-in functions: declaration like

function Func(x as double)
 ..

doesn't help, either.

Of course, if I wanted to reference cells by their addresses, I better simply
use it like "=Func(A1)", and dragged the formula so that it will point to
relative cell in each place. But the real purpose for this is to be able to use
named ranges in the function. In complex formulas, it is very inconvenient to
reference cells by addresses, but rather by names set in Insert->Names.

>From discussion at
http://forum.openoffice.org/en/forum/viewtopic.php?f=44&t=27860 and similar, I
already know that it's impossible to get the calling cell address from within
the code.

So, the request is to provide a means to get only one value from a relative
cell in the range passed to a Basic function.
As an option, I suggest to distinguish when the function argument is declared
explicitly as a scalar.
Other option could be to allow to get the information about the cell in which
the formula resides.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to