Page 1 of 1

Does OpenOffice.org BASIC have enums?

Posted: Fri Jun 15, 2012 12:29 pm
by Will Pittenger
I noticed the IDE highlights "enum" as a keyword. But it doesn't like the syntax I used. I tried using standard VBA syntax I found on the web as shown below. But the compiler claims it is expecting a sub at the enum keyword. Did they reserve all keywords used by VBA without implementing some?

Code: Select all

enum Test
  value = 1
  value2 = 2
end enum

Re: Does OpenOffice.org BASIC have enums?

Posted: Fri Jun 15, 2012 12:39 pm
by RoryOF
I can't answer your problem in any detail, but you are making a fundamental error in assuming that OpenOffice recognises and honours VBA syntax. The language used is completely different. You need to look at the documentation in detail. Start with
OpenOffice BASIC programming Guide
and the API info linked off
http://www.openoffice.org/api/

Re: Does OpenOffice.org BASIC have enums?

Posted: Fri Jun 15, 2012 1:59 pm
by Hagar Delest
Plenty of topics with enum in the macro section and the code snippet.
See for example: Close all opened Writer documents.

Please add '[Solved]' at the beginning of your first post title (edit button) if your issue has been fixed.

Re: Does OpenOffice.org BASIC have enums?

Posted: Fri Jun 15, 2012 2:29 pm
by Charlie Young
Hagar Delest wrote:Plenty of topics with enum in the macro section and the code snippet.
See for example: Close all opened Writer documents.

Please add '[Solved]' at the beginning of your first post title (edit button) if your issue has been fixed.
I don't think Will is referring to enumerations of UNO objects, though they are highly useful; I think he wants a named list. I don't think OOBasic implements that directly, though with a certain amount of awkwardness something similar can be done with Array().

Re: Does OpenOffice.org BASIC have enums?

Posted: Fri Jun 15, 2012 2:34 pm
by Villeroy
The primitive StarBasic language does not know any enums. Any mature programming language (Java, Python, JavaScript, ...) knows some type of key:value pairings.

Re: Does OpenOffice.org BASIC have enums?

Posted: Sat Jun 16, 2012 1:53 am
by Will Pittenger
Villeroy wrote:The primitive StarBasic language does not know any enums. Any mature programming language (Java, Python, JavaScript, ...) knows some type of key:value pairings.
Figures. So why does it treat "enum" as a keyword when it comes to syntax highlighting? :?

Re: Does OpenOffice.org BASIC have enums?

Posted: Sat Jun 16, 2012 9:12 am
by RPG
Hello

It is a know fact that it is possible to activate VBA support in Star Basic. It is not clear to me if it a good habit to activate it but for old VBA programmers who really understand that language and also can program maybe it is good to do it. But this group programmers is small.

This is working for me:

Code: Select all

REM  *****  BASIC  *****
option VBAsupport 1

enum Test2
  value = 1
  value2 = 2
end enum

Sub Main
print test.value
End Sub

and also this:

Code: Select all

REM  *****  BASIC  *****
option Compatible
enum Test
  value = 1
  value2 = 2
end enum

Sub Main
CompatibilityMode(True)
print test.value
End Sub
Romke