On Thu, 18 May 2017, alexchernoff wrote: > Good day all, > > is there a way to have a routine execute in a class as soon as a new > instance of it is created? I have a Public Sub Main() but it doesn't seem to > run. > > I come to Gambas from Xojo and there classes have a Constructor() sub which > runs on init. > > thanks! >
The constructor is called _new in Gambas (see [1]): Public Sub _new() ' runs on object creation End You can also specify parameters to the _new() method like ' In MyClass.class: Public Sub _new(X As Integer) ' ... End which demands that an Integer be given on object instantiation: Dim h As New MyClass(10) ' X = 10 Regards, Tobi [1] http://gambaswiki.org/wiki/cat/special -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user