| View previous topic :: View next topic |
| Author |
Message |
simona Newbie

Joined: 30 Aug 2004 Posts: 2
|
Posted: Mon Aug 30, 2004 4:26 pm Post subject: Questions about types and arrays |
|
|
Hi,
i have some questions about userdefined types and assigning arrays of these types.
How can i define a global type? Something like
global type Point
x As Double
y As Double
end type
isnt accepted. If i define it just with type it seems to have a local scope in the module where its defined.
Now to my array problem:
If i do something like
dim p1 as point
dim p2 as point
p1.x = 1
p1.y = 2
p2 = p1
p2.x = 3
the value of p1.x is still 1. So i assume assignment is done by copying the structure and not by assigning a reference to the same structure.
(The same happens with structs from the star api like com.sun.star.awt.Point)
If im right, why isnt it possible to do
dim p1 as point
p1.x = 1
p1.y = 2
dim p(1) as point
p(1) = p1
?? After these lines there is still
p(1).x == p(1).y == 0 ???
I admit i use an older version of oo (v 1.1.1).
Thanx in advance,
simon. |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3622 Location: Columbus, Ohio, USA
|
Posted: Wed Sep 01, 2004 6:50 pm Post subject: |
|
|
I was just asked this by email... Here is the email that I sent in reply...
Hi Ian,
I am in a hurry at the moment so I will be brief for now...
I have an example in my free macro document called
User Defined Data Types
It is very brief... I have some more coverage in my book... I will have very good coverage of this for my presenation in Berlin at the conference.
| Code: | 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 |
I have found that sometimes defining your own types can cause OpenOffice to crash. This is a very new feature...
Andrew Pitonyak _________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
|