Code: Select all
TYPE athing
x AS INTEGER
END TYPE
TYPE collection
thing AS athing
END TYPE
DIM somethings(10) as athing
DIM manythings(10) as collection
somethings(0).x = 10
manythings(0) = somethings(0)
PRINT manythings(0).x
Code: Select all
TYPE athing
x AS INTEGER
END TYPE
TYPE collection
thing AS athing
END TYPE
DIM somethings(10) as athing
DIM manythings(10) as collection
somethings(0).x = 10
manythings(0) = somethings(0)
PRINT manythings(0).x
Code: Select all
TYPE athing
x AS INTEGER
END TYPE
TYPE collection
thing AS athing
END TYPE
DIM somethings(10) as athing
DIM manythings(10) as collection
somethings(0).x = 10
manythings(0).thing = somethings(0)
PRINT manythings(0).thing.x
Code: Select all
TYPE athing
x AS INTEGER
END TYPE
TYPE collection
thing AS athing
declare operator _
let( _
byref as athing )
declare operator _
cast() as athing
END TYPE
operator _
collection.let( _
byref rhs as athing )
thing => rhs
end operator
operator _
collection.cast() _
as athing
return( thing )
end operator
operator _
->( _
byref lhs as collection ) _
as athing
return( lhs.thing )
end operator
DIM somethings(10) as athing
DIM manythings(10) as collection
somethings(0).x = 10
manythings(0) = somethings(0)
? manythings( 0 )->x
sleep()
Code: Select all
TYPE athing
x AS INTEGER
END TYPE
TYPE collection
thing AS athing
END TYPE
DIM somethings(10) as athing
DIM manythings(10) as collection
somethings(0).x = 10
manythings(0).thing = somethings(0)
PRINT manythings(0).thing.x
"Great minds think alike?" or "fools seldom differ?” :-)fxm wrote:Exactly the above badidea's post (first response).
Code: Select all
const MAX_SONGS = 30 'per album
const MAX_ALBUMS = 200 'per collection
const MAX_COLLECTIONS = 50
type song_type
dim as string*200 artist
dim as string*200 title
dim as ulong releaseYear
dim as ulong track
dim as ulong side
end type
type album_type
dim as string*200 title
dim as ulong numSongs
dim as song_type song(MAX_SONGS-1)
end type
type collection_type
dim as string*200 owner
dim as ulong numAlbums
dim as album_type album(MAX_ALBUMS-1)
end type
dim as ulong numCollections
dim shared as collection_type collection(MAX_COLLECTIONS-1)
numCollections = 1
collection(0).owner = "badidea"
collection(0).numAlbums = 1
collection(0).album(0).title = "ABBA Arival"
collection(0).album(0).numSongs = 2
collection(0).album(0).song(0) = type("ABBA", "Dancing Queen", 1976, 2, 1)
collection(0).album(0).song(1) = type("ABBA", "Money, Money, Money", 1976, 1, 2)
numCollections = 2
collection(1).owner = "Pjbonovox"
collection(1).numAlbums = 1
collection(1).album(0) = collection(0).album(0) 'copy album
'show all, crazy use of nexted with :-)
for iCollection as integer = 0 to numCollections-1
with collection(iCollection)
print trim(.owner); " - "; .numAlbums
for iAlbum as integer = 0 to .numAlbums-1
with .album(iAlbum)
print trim(.title); " - "; .numSongs
for iSong as integer = 0 to .numSongs-1
with .song(iSong)
print trim(.artist); " - "; trim(.title); " - "; .releaseYear; " - "; .track; " - "; .side
end with
next
end with
next
end with
next
Code: Select all
numCollections = 1
'collection(0).owner = "badidea"
'collection(0).numAlbums = 1
'collection(0).album(0).title = "ABBA Arival"
'collection(0).album(0).numSongs = 2
'collection(0).album(0).song(0) = type("ABBA", "Dancing Queen", 1976, 2, 1)
'collection(0).album(0).song(1) = type("ABBA", "Money, Money, Money", 1976, 1, 2)
collection(0) = type("badidea", 1, {type<album_type>("ABBA Arival", 2, {type<song_type>("ABBA", "Dancing Queen", 1976, 2, 1), type<song_type>("ABBA", "Money, Money, Money", 1976, 1, 2)})})
numCollections = 2
'collection(1).owner = "Pjbonovox"
'collection(1).numAlbums = 1
'collection(1).album(0) = collection(0).album(0) 'copy album
collection(1) = type("Pjbonovox", 1, {collection(0).album(0)})