OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Questions about types and arrays

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
simona
Newbie
Newbie


Joined: 30 Aug 2004
Posts: 2

PostPosted: Mon Aug 30, 2004 4:26 pm    Post subject: Questions about types and arrays Reply with quote

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
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Wed Sep 01, 2004 6:50 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Thu Sep 02, 2004 5:51 am    Post subject: Reply with quote

This link might be useful, as well:
http://www.oooforum.org/forum/viewtopic.php?t=10967&highlight=object+oriented

Christian
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Sat Apr 09, 2005 8:29 am    Post subject: Reply with quote

Cross references....

Structs in StarBasic
http://www.oooforum.org/forum/viewtopic.phtml?t=18948
http://www.oooforum.org/forum/viewtopic.php?t=12032
http://www.oooforum.org/forum/viewtopic.php?t=10967

Array Semantics
http://www.oooforum.org/forum/viewtopic.php?t=4615
http://www.oooforum.org/forum/viewtopic.php?t=4608
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group