In essence, I'm not sure you can, although there might be a way using reflection. However, I thought it might be worth mentioning a few points about your code.
1. When a new type instance is created, the New() method is run for the new type instance. Remember, a BlitzMax function doesn't have a type instance associated with it - you can call functions without a specific instance, for example...
3. Finally, I think it's bad practice to put parentheses "()" after your end keywords. You don't need them.
How about something like this:
1. When a new type instance is created, the New() method is run for the new type instance. Remember, a BlitzMax function doesn't have a type instance associated with it - you can call functions without a specific instance, for example...
TBall.myFunction()You wouldn't be able to do that with a method. You'd have to make a new ball, and then call the method with it.
Local tmpBall:TBall = New TBall tmpBall.myMethod()2. I see what you are trying to do but I'm not entirely sure it can be done that way, unless you start using reflection. Instead, you may want to add functions to each type to count how many of its own type it can find.
3. Finally, I think it's bad practice to put parentheses "()" after your end keywords. You don't need them.
How about something like this:
Global lstObjects:TList = New TList Type TBall Method New() 'The New() you are attempting to use, is actually a method. lstObjects.Addlast(Self) EndMethod Function CountInList( pList:TList ) Local i% For Local tmpBall:TBall = EachIn pList i:+1 Next Return i EndFunction EndType Type TDrWatson Method New() lstObjects.Addlast(Self) EndMethod Function CountInList( pList:TList ) Local i% For Local tmpDrWatson:TDrWatson = EachIn pList i:+1 Next Return i EndFunction EndType New TBall New TBall New TDrWatson Print "Total No. of Objects: "+ lstObjects.Count() Print "No. of Balls: " + TBall.CountInList( lstObjects ) Print "No. of Dr Watsons: " + TDrWatson.CountInList( lstObjects )Hope this helps! :-)