How to add user-defined function to the Function List

Hello.

I created a new function into libreoffice basic IDE.
My question is, why when I type one or more letters of my function, like the rest of the functions that are by default in functions list, the full name does not appear and if I press Enter key that function is not inserted? :thinking:

REM  *****  BASIC  *****

function Afshin(b,h)
	Afshin=(b*h)/2
end function

there is no way for poor-mans-basic-UDFs, if you want a full featured Function you need to create a Addin. A proof-of-concept was discussed here

3 Likes

I mean there is a function list in Calc.

I want My created function add to this list.
Is there an easy way wihout make an Add-On?

The correct answer is

2 Likes

OK, Thanks but let me to ask this quistion:

Why adding user-defined function is related to Add-in?
Why can’t a function be added to the list of functions without creating a Add-in? :thinking:

Because of many aspects.

  1. A macro does not advertise itself in a proper way. It does not tell its arguments properly, and its return value, in terms of Calc types (even if it does that in language-specific way).
  2. A macro UDF does not distinguish itself from non-ODF neighbor functions.
  3. The program only learns about macros available in a library/module after it’s loaded. We do not load all Basic, Java, Python, Javascript, etc. macros in advance. That would be problematic, e.g. give errors from incomplete modules, etc.; and people who didn’t define UDFs at all, would get the noise from all the tool functions already there.

The proper way is add-ons. They explicitly register their functions as “designed for Calc”.

1 Like

@mikekaganski
Surely the reasons you listed are valid, but also surely there could be specified a range (libraries) of specially accessible user code from where UDF interfaces would be read and imported (re-formatted) to the formula wizard’s database on LibO startup if properly shaped and regarding some restrictions. A PropertyBag for UDF interfaces?

I don’t think it’s reasonable to try to introduce something like that, prone to user errors, when there is already a proper way to do this.