On 2011-08-18 12:11, Johnny Rosenberg wrote:
I was, in a reply to another question, told that my questions were way
too basic for the dev@api.OpenOffice.org list, so I'll give it a try
here instead.
I wrote some example code:
REM ***** BASIC *****
Option Compatible
Option Explicit
Type MyType
a As Integer
b As Integer
End Type
Dim x(1) As MyType
Sub Main
Dim y As MyType
Dim i As Integer
For i=0 To 1
x(i).a=1+i*2
x(i).b=2+i*2
Next i
y.a=5
y.b=6
MsgBox x(0).a& x(0).b& x(1).a& x(1).b& y.a& y.b ' Displays 123456
ReDim x(1) As MyType
ReDim y As MyType
MsgBox x(0).a& x(0).b& x(1).a& x(1).b& y.a& y.b ' Displays 123400
End Sub
So if we have an array as MyType (or any other custom type, I
suppose), ReDim will not reset it.
Is this the expected behaviour or should I write a bug report?
If it is expected, why?
I guess it's unnecessary to mention that I am a complete beginner in
everything that has anything to do with computers; we guitar players
are quite stupid, you know.
Oh, and in case it matters:
LibreOffice 3.3.3, Ubuntu 10.10.
LibreOffice installed with the debs at http://www.libreoffice.org/.
Best regards
Johnny ”The Moron” Rosenberg
ジョニー・ローゼンバーグ
Johnny:
'Dim x(1) As MyType' is a static array. ReDim is for use with dynamic arrays.
Dim x() as MyType 'Dynamic Array
sub main()
ReDim x(1) as MyType
...
...
End sub
Dim y as MyType is a variable, not an array, so ReDim should not work. But it does apparently,
which may be the actual bug, unless there is a nuance I am missing. Excel 03 does not allow it.
Strangely enough I could get your code to work in Excel with the correct usage of the ReDim (minus
the ReDim y variable), but could not get it to work in LibreOffice. Ran out of time as it is way
past my bedtime.
TomW
--
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.