Function with arguments returns #null after load

Hi all,

I use the LibreOffice Version: 6.0.7.3 on a Ubuntu system: Build ID: 1:6.0.7-0ubuntu0.18.04.10

I have the following problem with the LibreOffice.Calc:

I use the following functions in the LibreOffice.Basic:

Function Test20(year_) As Double
 Test20=year_
End Function

Function Test30() As Double
 Test30=30
End Function

When I call these functions in LibreOffice.Basic they produce the expected results.
When I call these function in LibreOffice.Calc then I get also the results as expected.
But when I now save the calc document to disc and load it again then the function, Test20(), with the parameter will produce the result #null.
The other function, Test30(), gives the expected result.
The only way to get it working again is to change the basic code and undo the changes.
After compiling the code again then the functions works again.

Can anybody give me a clue of what is happing here and how to solve the problem.
I already tryed it with the link:

https://stackoverflow.com/questions/39227757/libreoffice-macro-always-show-null-after-reopening-the-file

but that does not solve my problem.

Regards.

rammy

(Slightly edited for better readability by @Lupp.)

I cannot confirm this to be a general issue. Just installed LibreOffice 6.0.7.3 on ubuntu0.18.04 and tested the functions inside a module of the document and as well the functions stored in My Macros (stored in User Profile).In both cases no problem, when re-opening the file.

Thus my question is: Have you already tried to run LibreOffice in Safe Mode and to repeat your test, to check whether a LibreOffice user profile corruption may cause the problem?

-1- Please use the editing tool Preformatted Text for Basic code,
-2- I seem to remember there once were problems with Basic if chosen names had trailing underscores.
(My memory is not exactly clear insofar.)

Additional explanation:
A insuklated underscore at the end of the line makes this line and the next one syntactically one line (“soft break”). One or another version parsed the source wrongly with this respect under certain conditions.
If possible for you, pleas test with variable/parameter names avoiding underscores …
You may also test with a colon behind the underscore. (Syntactically creating a new line of code.)
A report about your results would be welcome.

That line continuation is actually a BASIC language feature, but it should take a space and an underscore as last characters on a line to trigger that. Maybe some version got that wrong?
See also The Basic Editor second paragraph.

I can´t test in save mode because the macros are then disabled.

Hi all,

I investigated the problem further and found that the couse of the problem is the use of the, Option VBASupport 1, command at the beginning of the module. When I remove that line than the call from calc gives the correct results.

I thank you all for your thoughts and think along.
I added an example file for testing.

Regards.

rammy

Untitled 1.ods

Hi mike, when I run your adapted calc file then I get the expected results, see Screenshot_2020-01-08_00-27-30.png. Maybe they solve the problem in your LibreOffice version?

I can’t reproduce with version 6.4.0.1 (see this modified spreadsheet containing your data plus a copy of the module with VBASupport enabled, so that both may be viewed side-by-side).

Could you please try with a newer version? Just register this PPA and run system’s application updater - no need to uninstall anything.

I used your PPA link and are now using LibreOffice Version: 6.3.4.2 on a Ubuntu Build ID: 1:6.3.4-0ubuntu0.18.04.1~lo2. When I now run your modified spreadsheet then I get the results that I would expect.