OpenOffice.org Basic – Arrays as pa rameters in functions

Johnny Rosenberg <[email protected]> Fri, 12 Aug 2011 19:52:47 +0200
Newsgroups gmane.comp.openoffice.devel.api,gmane.comp.openoffice.questions,gmane.comp.documentfoundation.libreoffice.user
Message-ID <CADo7T4e__aQ1o_5LD8aFt_1iUcnVcLFowRA9q=xgAdN=Lf_YFg@mail.gmail.com>
Let's say I have this array:

Type MyType
	A As String
	B As Long
End Type

Sub Main
	Dim MyArray(0) As MyType, i As Long

'	A lot of stuff going on

	For i=3D1 To Something
		ReDim Preserve
		MyArray(i).A=3DgetStuffFromSomewhere()
		MyArray(i).B=3DgetStuffFromOuterSpace()
	Next i

'	More stuff going on for quite a while
End Sub

So I have a big array of my own type. Now I want a function to do
things based on the contents of MyArray. I know I can do this:

Function MyFunction(AnArray As Variant)
'	Do things
End Function

So my question is, if I don't want to use the parameter-as-variant
method, is there another way?
I guess I could do something like the following:

Function MyFunction(AnArray(Something) As MyType)
'	Do things
End Function

The problem is that =E2=80=9DSomething=E2=80=9D is just that, something, no=
t a known value.
Using the variant trick seems to be cheating to me=E2=80=A6 Is it the only =
way
to go, really?


Kind regards

Johnny Rosenberg
=E3=82=B8=E3=83=A7=E3=83=8B=E3=83=BC=E3=83=BB=E3=83=AD=E3=83=BC=E3=82=BC=E3=
=83=B3=E3=83=90=E3=83=BC=E3=82=B0
--=20
-----------------------------------------------------------------
To unsubscribe send email to [email protected]
For additional commands send email to [email protected]
with Subject: help