Hi again!
Let's say that I modify your example as follows:
Type MyType
aName as String
aAge as Integer
Things() as String
End Type
Sub Main Dim mt(20) As New MyType mt(13).aName = "Tom" mt(13).aAge = 42
Msgbox mt.aName & ", " & mt.aAge End Sub
I guess I could REDIM the whole mt() by just adding something like: REDIM mt(40)
But what about, for example, mt(17).Things? REDIM mt(17).Things(200) And maybe Tom has only 78 Things, like REDIM mt(13).Things(78)
Is this allowed and will it work? I only want to REDIM Things for ONE of the mt elements.
Does this make any sense?
Best regards Johnny
Andreas Bregas <[EMAIL PROTECTED]> skrev den Fri, 20 May 2005 10:34:46 +0200:
Hi Johnny,
first, I think [email protected] would be more appropriate for questions like yours.
But there is something like "struct" in Basic, the Type command. I think it's available since OOo 1.1.4. Example:
REM ***** BASIC ***** Type MyType aName as String aAge as Integer End Type
Sub Main Dim mt As New MyType mt.aName = "Tom" mt.aAge = 42 Msgbox mt.aName & ", " & mt.aAge End Sub
I hope that's what you thought of.
Regards
Andreas
Andersson schrieb:I studied the built in help and it really didn't help me at all. I also looked for it in the free macro manual, but I didn't find anything so far.
I would like to be able to declare something that works like struct or class in c++, which I would believe would be an object in StarBasic. Is this possible and in that case, how? A simple example perharps?
If this is not possible, I guess that some kind of array would do.
Will this example bekow work, and is there an easier way to do this (except declaring as Variant and then later let the different element be whatever they are assigned to)?
Dim MyArray(1 To 1,9) As String, MyArray(2 To 2,9) As Integer, MyArray(3 To 3,9) As Date
What I want to do is the following, if not obvious:
MyArray(1,0) to MyArray(1,9) are string variables.
MyArray(2,0) to MyArray(2,9) are integer variables.
MyArray(3,0) to MyArray(3,9) are date variables.
This way I could fake my own kind of c++ structures by declaring some constants like the following example:
Const PlayerName=1
Const PlayerPoints=2
Const PlayerDate=3
Dim Player As Integer
Dim Players(1 To 3, 9) As Variant
Players=SetEverything(Players) ' Supposed to return relevant data...
For Player=0 To 9
Print Players(PlayerName,Player)+", "+Players(PlayerPoints,Player)+" p, "+Players(PlayerDate,Player)
Next Player
Am I totally out of sense here?
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
