Question about Types
BlitzMax Forums/BlitzMax Beginners Area/Question about Types
| ||
I don't get this about Types. When I create a type with some fields, like that: Type Score Field Score_x Field Score_y End Type And I create a Type later on... b = New Score b.Score_x = 25 I get the error "Identifiere Score_x not foun". Shouldn't fields not be global like in Blitz3d??? I don't get it... And how can I go trough all my types? EachIn seems not to work. Thanks for your help |
| ||
b:Score = new Score |
| ||
Ah, yes thats an error, thanks. I can now go through my types using a list, too. But how can I delete a type? "Delete" seem not to work, so dont "RemoveList" |
| ||
You don't "delete", you "release". The garbage collector will free the memory when it gets around to it... |
| ||
Okay, got it. Thanks pal, you're the best :) |
| ||
I try. :) |
| ||
Hi, is there a way to declare a field in a type as private? In my module i am using a method for setting a field, so the field can't take wrong values. But anyone can change the field directly.. that shouldn't be possible in my case. |
| ||
there are private and public commands but I'm not sure if you can use them in types. |
| ||
you can't make fileds Private or Public The Private and Public keywords are merely there for making sections of code accessible outside the current sourcefile or not. Type Foo Field Foobar:String Method New() Foobar = MyEnum.First End Method End Field '// everything below this keyword is only accessible from within this sourcefile. '// Calling it outside this sourcefile will generate an error. Private Type MyEnum Const First:String = "1", .. Second:String = "2" End Type So the above will only work if Type Foo is in the same file as MyEnum. The Public keyword is applied by default. So if you dont use these keywords, everything is Public automaticly. |
| ||
thx ok it would be a nice feature, but it's not a problem ;) |
| ||
ok it would be a nice feature, but it's not a problem ;) Second that. Same with constructors. |
| ||
b:Score = new Score I can see the convenience of specifying b's type for the compiler/translater itself but wouldn't it be more convenient for programmers if, where "new" is used, the type is inferred from the rhs? |