Bug 139457 - Loading libraries with GlobalScope not working as described in LO Help
Summary: Loading libraries with GlobalScope not working as described in LO Help
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.1.0.1 rc
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-06 23:06 UTC by Rafael Lima
Modified: 2021-09-20 09:03 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
File with the Basic code described in the bug report (8.03 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-01-06 23:06 UTC, Rafael Lima
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Lima 2021-01-06 23:06:31 UTC
Created attachment 168728 [details]
File with the Basic code described in the bug report

Hi! Help pages about Basic libraries state that the library must be loaded by placing the GlobalScope.BasicLibraries.LoadLibrary("Library Name") statement before the first macro in the module.

For example, the Help page for the Tools Library says: "This library must be loaded before execution. Place the following statement before the first macro in your module:
GlobalScope.BasicLibraries.LoadLibrary("Tools")"

Link:
https://help.libreoffice.org/7.1/en-US/text/sbasic/shared/03/lib_tools.html?DbPAR=BASIC#bm_id491529070339774

The problem is that these instructions don't seem correct. If I create a new module in the Standard library of a new file and enter the following code (see that the library is loaded before the first macro):

----------------
GlobalScope.BasicLibraries.LoadLibrary("Tools")

Sub Main
  'Just some random code to showcase the error
  MsgBox "Hello"
End Sub
----------------

Now, if I run the Main macro, I get the error message "BASIC syntax error. Expected: Sub."

However, if I place the LoadLibrary statement inside the Sub, everything works fine.

I am reporting this because this issue is either a bug in the Basic interpreter or it is something that needs fixing in the Help pages.

I attached a ODS file with the example above for testing.
Comment 1 Rafael Lima 2021-02-12 12:20:19 UTC
This bug was fixed by the following patch:

https://gerrit.libreoffice.org/c/help/+/110366

Among other things, this patch changed the message explaining how to load libraries. The message now provides correct instructions.