2

I'm writing a macro for LibreOffice Calc in Basic in VBA compatibility mode. It complains when I use this line:

Const BASE = 3

BASIC syntax error.
Symbol expected.

and the syntax coloring seems to indicate that "BASE" is a keyword or reserved word. Other consts in the macro are accepted without issue. Also, this line is accepted in VBA in Excel.

I will change the name in order to avoid this problem, however I am unable to locate any documentation that references this as being any kind of reserved word. I assume it either has something to do with number bases or with the name of LO's database. However, words like "WRITER" and "CALC" don't act the same way - they seem to be accepted as names for constants. Note that my use of this word is not related to the database anyway.

Also, unfortunately, LO Basic doesn't seem to have an immediate mode (REPL) so I am unable to easily play with this word to determine what it's used for.

Can you point me toward some documentation for the keyword BASE?

Dennis Williamson
  • 346,391
  • 90
  • 374
  • 439

1 Answers1

1

Those are some good guesses, but incorrect as it turns out. The word is used as follows:

Option Base 1

It can be either 0 or 1 to denote which index refers to the first element of an array, as documented at https://wiki.openoffice.org/wiki/G11ntest/Documentation/BASIC_Guide/Arrays.

To discover this, I looked through the LibreOffice source code. The file /basic/source/inc/parser.hxx was helpful. This is the closest approximation of a list of keywords available, judging from this post.

Apparently, this statement was adopted from VBA: https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/option-base-statement

Jim K
  • 12,824
  • 2
  • 22
  • 51
  • Thanks. That's the one alternative that didn't come to mind. The OO wiki page you linked to is truly awful. I found this LibreOffice page on [`Option Base`](https://help.libreoffice.org/6.2/en-US/text/sbasic/shared/03103200.html) that's formatted much better. – Dennis Williamson May 06 '19 at 16:41
  • One more comment that may be slightly outside the scope of the question: Python-UNO is generally preferred over LO Basic nowadays. It has well-documented keywords and a live prompt like the VBA immediate mode. – Jim K May 06 '19 at 16:43
  • Yes, I'm most likely switching to Python, because Basic - yuck. – Dennis Williamson May 06 '19 at 16:45
  • Glad to hear it. – Jim K May 06 '19 at 16:45