Object To Custom Type?

BlitzMax Forums/BlitzMax Beginners Area/Object To Custom Type?

Rixarn(Posted 2008) [#1]
Hi! iīm really stuck here...i donīt grasp the use of Object very well.

GadgetItemExtra returns an Object, but how can i access that objectīs fields? Letīs say my extra object was a string, or another custom type object... how can i convert the Object returned, to my custum type object inserted? or access the string or custom object fields?

Thanks in advance!


GfK(Posted 2008) [#2]
That a MaxGUI thing? Anyway, you have to cast the object back to the original type:
m:myType = myType(GadgetItemExtra())

x = myType.whatever



Rixarn(Posted 2008) [#3]
Well, not a MaxGui Think actually... i just tried to explain myself with a built in command and that came up... but Omg i totally forgot about cast and even then... i didnīt knew you could cast objects in Bmax...

Thanks a lot!


ziggy(Posted 2008) [#4]
Local MyCustomObject:TCustomObject = TCustomObject(PlainObject)

where:
MyCustomObject is the variable that will point the object with the apropiate fields, methods, etc.
TCustomObject is the name of the type for MyCustomObject
PlainObject Is the object to cast from. The base Object.