Issue 118031 - Allow to declare a Constant dependent of a Public Constant declared in another module.
Summary: Allow to declare a Constant dependent of a Public Constant declared in anothe...
Alias: None
Product: Calc
Classification: Application
Component: programming (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC All
: P3 Normal (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
Depends on:
Reported: 2011-05-16 13:01 UTC by georgewood1155
Modified: 2014-04-05 15:49 UTC (History)
4 users (show)

See Also:
Latest Confirmation in: ---
Developer Difficulty: ---

calc spreadsheet with macro example of problem with Public Constant (9.72 KB, application/vnd.oasis.opendocument.spreadsheet)
2011-05-20 08:47 UTC, georgewood1155
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description georgewood1155 2011-05-16 13:01:02 UTC
I am attempting to use constants declared in one module in another where both modules are in the same library.


Module A code:
REM  *****  BASIC  *****
Dim Col_A as Integer

Sub Main
Col_A = 0
End Sub


Module B code:
REM  *****  BASIC  *****
Dim MD_Col as Integer

Sub Main
MD_Col = Col_A
'another holder
End Sub


Compiling results in a popup window showing the following error:
BASIC syntax error. Syntax error. 
With Col_A in Module B highlighted.
Comment 1 bmarcelly 2011-05-16 17:08:39 UTC
Your code has nothing to do with constants, and it works.

Please rewrite your code, or better create a document with the error and add it as attachment.
Comment 2 georgewood1155 2011-05-20 08:47:38 UTC
Created attachment 76527 [details]
calc spreadsheet with macro example of problem with Public Constant

attachment is a spreadsheet with a library named Example that contains two macros using the Public Constant in modules. Compiling the Use_Constant module results in a Basic Syntax Error.
Comment 3 Oliver-Rainer Wittmann 2012-06-13 12:32:50 UTC
getting rid of value "enhancement" for field "severity".
For enhancement the field "issue type" shall be used.
Comment 4 Edwin Sharp 2013-11-23 18:41:06 UTC
BASIC syntax error.
Syntax error.

AOO410m1(Build:9750)  -  Rev. 1539999
2013-11-09_04:08:11 - Rev. 1540252
Comment 5 Rainer Bielefeld 2014-04-04 07:46:20 UTC
Version has been modified erroneous, so back to most early version

If the scripting code contains a syntax error the syntax error message is not an AOO bug ;-)

thank you for your feedback! Unfortunately you are wrong here, this is the AOO bug tracking system, not a helpdesk.
You can get assistance at
or here:<>
If you want to report bugs please consider hints on  <>
Please feel free to reopen this Bug if discussion with other users leaded to an assessment that we have an AOO bug with a current AOO Version and a clear and comprehensible description how to reproduce the problem due to above mentioned guidelines. 
Comment 6 bmarcelly 2014-04-04 08:48:48 UTC
I disagree with the new status. The problem is reproducible.

You cannot declare a constant dependent of a Public constant declared in another module.
The syntax error clearly shows that OpenOffice Basic does not accept this.

Of course you can declare a *variable* and assign to it an expression depending on a Public constant of another module. 

So either close it as RESOLVED / INVALID, or better reconsider it as Issue Type  ENHANCEMENT.
Comment 7 Rainer Bielefeld 2014-04-04 08:57:49 UTC
Due to skilled examination Comment 6

Probably not Linux related
Comment 8 Rainer Bielefeld 2014-04-04 08:58:10 UTC
CONFIRMED due to Comment 6
Comment 9 mroe 2014-04-04 09:02:13 UTC
Comment 5 was right!

Comment 1 shows a working Code but it isn't the same as in the document.
Comment 10 mroe 2014-04-04 09:08:11 UTC
Sorry, I was to quick with my comment!
Comment 11 mroe 2014-04-04 09:49:37 UTC
With your better description of this bug I tried a little bit more to understand the behaviour.

Now I found the explanation by myself:

You can use constants outside a module without any problems but you _must not_ assign a constant from outside the module to a constant!
The reason is to prevent such as:


Const Const1 = Const2


Const Const2 = Const1

But it seems that it isn't documented anywhere.
Comment 12 mroe 2014-04-04 15:30:58 UTC
Again. I don't know the implementation of the elements of basic code.
But with further tests I see that all declarations with potentially not static values will result in a Basic Syntax Error.

Try following:
Option Explicit

Sub Main
Dim VarInt01 As Integer
VarInt01 = 23
Const ConstInt01 = 2 * VarInt01
End Sub

So I conclude that a constant from outside of a module is simply read like a variable. With that and the fact that constants are recognized at compile time rather than run time I don't know if there is a chance for a change of this behaviour.

A constant should be a safe defined constant, but look at

Option Explicit
Sub Main
MsgBox c1
End Sub
Option Explicit
Public Const c1 = 23
Option Explicit
Public Const c1 = 47
Comment 13 bmarcelly 2014-04-05 10:38:57 UTC
-> mroe
Bugzilla is not a place discussion but I will answer your comment 12.

Your example 1 : Basic is right in stating it as a syntax error.

Your example 2 is a different bug.
If you feel it important, search if the problem is already reported and if not, create a bug report.

There are many bug reports or known limitations in OpenOffice Basic and few developers available to improve the compiler. However it is perfectly possible to write useful and elaborated macros in Basic if you are cautious.
Comment 14 mroe 2014-04-05 15:49:05 UTC
(In reply to bmarcelly from comment #13)
> -> mroe
> Bugzilla is not a place discussion but I will answer your comment 12.

I only tried to correct my misleading comment and tried to understand *why* the declaration of constant by a constant from outside the module is claimed as syntax error. But maybe there is no logical reason ...

Second example I don't saw as a bug. It should only illustrate "A constant should be a safe defined constant" but like the value of c1 with actual implementation it would mainly random if there are constants with the same name in other modules.