[Gambas-user] making objects of a class in a loop
Jochen Georges
jochengeorges at ...467...
Mon Jan 3 18:22:50 CET 2005
Hello gambanauts,
I would like to make a lot of objects in a loop.
this code is running, but it has got so much lines and the number of objects
is always the same.
'------------------------------------------------------------------
arFrage AS Object[]
fr_1 AS ClFrage
fr_2 AS ClFrage
fr_3 AS ClFrage
'------------------------------------------------------------------
PUBLIC SUB _new()
fr_1 = NEW ClFrage
fr_2 = NEW ClFrage
fr_3 = NEW ClFrage
arFrage = NEW Object[]
arFrage.add(fr_1)
arFrage.add(fr_2)
arFrage.add(fr_3)
END
'------------------------------------------------------------------
is there something like:
PUBLIC SUB _new(nb AS Integer)
i AS Integer
arFrage AS Object[]
for i = 0 to nb-1
ClFrage fr_i = NEW ClFrage
arFrage.add(fr_i)
next
END
??
How can i create a different number of objects, depending of a parameter?
More information about the User
mailing list