Can someone convert this BB code please?
BlitzMax Forums/BlitzMax Programming/Can someone convert this BB code please?
| ||
hi! if someone mids, please help me converting this one to bmax: ;blitz3d code: type typ1 field x, sub.typ2 end type type typ2 field y, sub.typ1 end type item1.typ1 = new typ1 item1\x = 10 item2.typ2 = new typ2 item2\y = 20 item2\sub = item1 item2\sub\sub = item2 obj1 = handle(item1) obj2.typ1 = object.typ1(obj1) i need this to learn the class constructs in bmax :) thanks! |
| ||
thats a joke, right? ;-) Even the bb importer could have done that. superstrict type typ1 field x:int field sub:typ2 end type type typ2 field y:int sub:typ1 end type local item1:typ1 = new typ1 item1.x = 10 local item2:typ2 = new typ2 item2.y = 20 item2.sub = item1 item2.sub.sub = item 2 the part below is not adviceable. The handleFromObject functionality makes BM seriously slower as BM is meant to use the typesafe object pointers you get from new (are not int handles anymore like in bb) instead of something else. object are always handle by reference so you can set them to a second instance without any problem. depending on what you want to achieve with that part, there are different far more powerfull solutions like TMap which allows to store objects by a key (which itself is an object, at simplest a string) |
| ||
SuperStrict Type typ1 Field x:Int, sub:typ2 End Type Type typ2 Field y:Int, sub:typ1 End Type Local item1:typ1 = New typ1 item1.x = 10 Local item2:typ2 = New typ2 item2.y = 20 item2.sub = item1 item2.sub.sub = item2 There is no need to use handle/object as each type instance is an object already rather than an int reference number as in B3D. It's recommended you use superstrict which means you need to declare your variables. I have guessed X/Y are int. I also think this is creating a cyclic reference which, I have heard, causes problem for the automatic Garbage collector (GC). |
| ||
ok. all i yet wanted to know is how to make that handle and object thing. but since i have to use :Int and :Float for all these things already, it makes sence as it is. thanks guys!! |
| ||
There is an importer??!!! <sigh> |