Ask Your Question
0

Function with arguments returns #null after load

asked 2020-01-06 00:26:47 +0200

rammy gravatar image

updated 2020-01-06 01:36:15 +0200

Lupp gravatar image

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.)

edit retag flag offensive close merge delete

Comments

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?

Opaque gravatar imageOpaque ( 2020-01-06 00:57:56 +0200 )edit

-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.)

Lupp gravatar imageLupp ( 2020-01-06 01:40:06 +0200 )edit

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.

Lupp gravatar imageLupp ( 2020-01-06 01:55:53 +0200 )edit

That line continuation is actually a BASIC language feature, but it should take a space and an underscoreas last characters on a line to trigger that. Maybe some version got that wrong? See also https://help.libreoffice.org/6.3/en-U... second paragraph.

erAck gravatar imageerAck ( 2020-01-06 16:31:51 +0200 )edit

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

rammy gravatar imagerammy ( 2020-01-08 00:57:02 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2020-01-06 20:53:46 +0200

rammy gravatar image

updated 2020-01-08 00:42:29 +0200

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

C:\fakepath\Untitled 1.ods

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

edit flag offensive delete link more

Comments

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).

Mike Kaganski gravatar imageMike Kaganski ( 2020-01-07 07:48:37 +0200 )edit

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

Mike Kaganski gravatar imageMike Kaganski ( 2020-01-08 06:08:45 +0200 )edit

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.

rammy gravatar imagerammy ( 2020-01-08 14:18:34 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-01-06 00:26:47 +0200

Seen: 57 times

Last updated: Jan 08