Johnny Andersson wrote:
2007/1/29, Andrew Douglas Pitonyak <[EMAIL PROTECTED]>:
What do you really want to accomplish? Do you want to copy a range of
data from one location to another? If so, you can use methods to
directly copy the data. I have used "cheat" methods such as
oCellRange1.setData(oCellRange2.getData())
No, a function will use the data (and other data) for calculation. The
function will return a value that will be written to another cell. The
function will be in a loop and use three of the values (one
column), different every time.
Very good. I assume that you now know how to do this.
> Another solution would perharps be to create a struct (as it's called
> in C),
> but is that possible in OpenOffice.org Basic?
Yes, you can create a user defined structure/type. To quote from my
AndrewMacro.odt document.
1.1. User Defined Data Types
As of OOo 1.1.1, you can define your own data types.
Listing 5.51: You can define your own data types.
Type PersonType
FirstName As String
LastName As String
End Type
Sub ExampleCreateNewType
Dim Person As PersonType
Person.FirstName = "Andrew"
Person.LastName = "Pitonyak"
PrintPerson(Person)
End Sub
Sub PrintPerson(x)
Print "Person = " & x.FirstName & " " & x.LastName
End Sub
Wow, I didn't know that! Now I have to rewrite everything macro and
every function I've made so far..!
They are not that many, on the other hand...
In your example above, is the following possible?
Sub ExampleCreateNewType
Dim Person(100) As PersonType
Person(0).FirstName = "Andrew"
Person(0).LastName = "Pitonyak"
PrintPerson(Person(0))
End Sub
Try it, yes, it works
And is the following possible?
Type PersonType
FirstName As String
LastName As String
ThingsToDo(9) As String
End Type
No, you can NOT have an array inside of a struct. You need to fake it:
Type PersonType
FirstName As String
LastName As String
REM You can NOT have an array inside a structure
REM ThingsToDo(9) As String
REM But you can fake it...
ThingsToDo As Variant
End Type
Sub ExampleCreateNewType
Dim Person As PersonType
Dim aa(9) As String
Person.FirstName = "Andrew"
Person.LastName = "Pitonyak"
Person.ThingsToDo = aa()
Print UBound(Person.ThingsToDo) REM Prints 9
Person.ThingsToDo = DimArray(9)
Print UBound(Person.ThingsToDo) REM Prints 9
'PrintPerson(Person)
End Sub
And finally, is the following possible?
Type PersonType
FirstName As String
LastName As String
End Type
Type Human
Properties As PersonType
Friends(9) As PersonType
End Type
You can not have an array inside of a struct. A struct in a struct,
however, is fine.
And even more finally, is there something similar to pointers in
OpenOffice.org Basic?
I demonstrate this in the presentation I referenced.
I gave a presentation at the 2004 OOo Conference in Berlin concerning
creating advanced data types using structures. The examples are in the
presentation available on my web site.
Interesting! I'd better take a look there then!
Thanks for your reply!
Johnny
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info: http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]