Apache OpenOffice (AOO) Bugzilla – Issue 18989
The LBound and UBound functions fail with empty arrays from DimArray and Array()
Last modified: 2004-06-10 09:42:21 UTC
the array a() is considered empty if LBound(a()) > UBound(a()). For example. Dim a() LBound(a()) = 0 UBound(a()) = -1 this is an empty array. a() = DimArray() a() = Array() both return an empty array that can not be used with LBound or UBound.
StarBASIC runtime, not API
I do not completely agree: Dim a() is a special contruct only created to allow defining arrays that represent a sequence of size 0. So the array created by Dim a() do contain one dimension of size 0 while the arrays created by DimArray() and Array() do not even contain a dimen- sion and it's not guaranteed anywhere that they should do. But ok, of course it would be more consistant if they did. So I will have a look and check if this can be changed without risking to break existing Basic code.
Had not thought of that! It is certainly true that ReDim works regardless. So Array() and DimArray return an array with no dimensions at all! Tricky!
As this was very easy to change and I saw no risk of breaking existing code, I fixed the behaviour according to your suggestion. In any case it's more con- sistant now.
To test: sub main a = DimArray() print lbound( a() ), ubound( a() ) a = Array() print lbound( a() ), ubound( a() ) end sub Should each display 0, -1 now.
Thanks AB, I appreciate this one! :-) Andrew Pitonyak
.
VERIFIED in ab08fixes
ok in src660_m41-5