Cell B2 on The KEYVALUE
function sheet of the example workbook contains a formula
calling the function
:KEYVALUE
=KEYVALUE
("Triangle";B3:C6)
This function call is meant to build a triangle.
We can see that cells with dark blue background contain formulas
calling
to build polygons and
to calculate their areas.KEYVALUE
There are no functions such as
,
BuildPolygon
or anything similar.
Indeed, regardless the core library,
CalculateArea
is the only function exported
to LibreOffice Calc.KEYVALUE
Actually, the name of this function is defined by the bridge
library. In the examplary bridge, this function is called
and, for the sake of
concreteness, in this document we shall always assume this name.KEYVALUE
Having just one function is not as odd as it might seem (one could
expect to call different functions for different tasks). Even when calling
a specific function for a precise task, the function might change its
behaviour depending on the data it receives. For instance, a function
would create a triangle or
a square (or whatever) depending on the number of sides given. KeyValue
goes one step further and considers the choice of the task as part of the
input data as well.CreatePolygon
Alternatively, we can think that
does have one single task: It
creates data sets. A data set is a
collection of data organized in key-value pairs (recall the stock prices
example given in Section 1). The example above
creates a data set called Triangle containing
key-value pairs defined by the array B3:C6 (more
details to follow). Analogously, the formula in cell
E2KEYVALUE
=KEYVALUE
("Square";E3:F6)
creates a data set called Square containing key-value pairs defined by array E3:F6.
More generally,
's first
parameter is the name of the data set to be created. This is a compulsory
parameter of text type (which might be left empty KEYVALUE
""
for
anonymous data sets). Moreover, as in
these examples, often the data set name is the result returned from
to LibreOffice Calc.KEYVALUE
Once created, a named data set is stored in a repository and might be retrieved later through its name.
Other
's parameters are
optional and define key-value pairs following patterns as discussed in
next section.KEYVALUE