Hi,

I am posting because I was astonished by the following, and I would like to understand it fully :

in my code I often use the same constant, for example : " com.sun.star.table.CellContentType.EMPTY" I thought that for readability reasons I could redefine this constant by another one very short : "EMPTY", that I would then define as follows :

Const EMPTY as Integer = com.sun.star.table.CellContentType.EMPTY

However to my surprise this did not work, as I receive "Syntax Error in Basic"

I asked confirmation about this to Dude, -you probably know him-, who explained me that indeed it was not possible to define this constant because "com.sun.star.table.CellContentType.EMPTY" is an /enumeration/.  He sent me to post here to get more details.

I do not understand why an enumeration cannot be assigned to a constant, although a /calculated expression/ can well be assigned to it ? If the basic would be compiled, I would agree that it is not possible to do so, because retrieving the value of the enumeration probably requires parsing a large table where all these constants are stored, and this can only be done in runtime. But as the basic is interpreted, I do not see the reason of not being able to do that.  Does anyone have an explanation ?

For your info, I tested the following workaround, which obviously works and does the job :
|
dim EMPTY as Integer||
 EMPTY = com.sun.star.table.CellContentType.EMPTY
 ...
|
And also for info, I tested out that running a loop of 1 million steps using this variable "EMPTY" in a comparison takes 2 seconds to execute, versus 6 seconds when using the enumeration in the comparison for the same loop. Good to know if an application has long loops.

Thanks for any answer that could improve my understanding of this great program.
Lucien.

Reply via email to