Bug 145753 - Enum Statement Basic documentation is misleading
Summary: Enum Statement Basic documentation is misleading
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Documentation (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-StarBasic
  Show dependency treegraph
 
Reported: 2021-11-18 11:09 UTC by Mike Kaganski
Modified: 2022-01-28 09:24 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2021-11-18 11:09:33 UTC
Enum Statement documentation [1] mentions Option VBASupport 1. This is wrong, since it depends on Option Compatible (that itself is implicitly activated by Option VBASupport 1, but may be used separately). The latter fact is mentioned on Option Compatible help page [2] "Statement Option VBAsupport 1 sets Option Compatible statement automatically", so no need to mention VBASupport here completely.

[1] https://help.libreoffice.org/7.2/en-US/text/sbasic/shared/enum.html

[2] https://help.libreoffice.org/7.2/en-US/text/sbasic/shared/compatible.html
Comment 1 Xisco Faulí 2021-11-23 10:05:19 UTC
Moving to NEW
Comment 2 Alain Romedenne 2021-11-29 14:08:05 UTC
When switching to Option Compatible, the Basic example in help does not function.

Please also note that an enumeration is always private, regardless of the Private/Public specifier that preceedes it.

The only way to make a Enum.eration public is to create a function that exposes it publicly.
Comment 3 Mike Kaganski 2021-11-29 14:17:10 UTC
(In reply to Alain Romedenne from comment #2)
> When switching to Option Compatible, the Basic example in help does not
> function.

That would mean a bug. Option Compatible indeed enables enums; e.g., with and without Option Compatible, (without VBASupport) you get different results compiling the module with enums - it would be a syntax error without Option Compatible. VBASupport should only change runtime, so inability to use compile-time structs is a bug.
Comment 4 Rafael Lima 2022-01-03 20:59:30 UTC
(In reply to Mike Kaganski from comment #3)
> That would mean a bug. Option Compatible indeed enables enums; e.g., with
> and without Option Compatible, (without VBASupport) you get different
> results compiling the module with enums - it would be a syntax error without
> Option Compatible. VBASupport should only change runtime, so inability to
> use compile-time structs is a bug.

The following code compiles both with "Option Compatible" and "Option VBASupport 1"; however it only runs with "Option VBASupport 1".

Enum eWindowManager
    WINDOWS = 1 ' Windows
    OS2PM = 2 ' OS/2 Presentation Manager
    MACINTOSH = 3 ' Macintosh
    MOTIF = 4 ' Motif Window Manager / Unix-like
    OPENLOOK = 5 ' Open Look / Unix-like
End Enum

Sub EnumTest
    MsgBox eWindowManager.WINDOWS
End Sub

@Mike, maybe Enum is supposed to be available only with VBASupport. See the following test, which uses VBASupport (not Option Compatible)
https://opengrok.libreoffice.org/xref/core/basic/qa/vba_tests/enum.vb?r=66b135fa
Comment 5 Alain Romedenne 2022-01-28 09:24:39 UTC
More information regarding Enum statement can be found in "Enum.erations or Constant groups" post at https://forum.openoffice.org/fr/forum/viewtopic.php?f=8&t=58988
See enum_en.odt attached file.