Object To Specific Type Translate

BlitzMax Forums/BlitzMax Programming/Object To Specific Type Translate

Hardcoal(Posted 2014) [#1]
Hi

Im trying to get a reply from a list as Type DataCell_Class using ValueAtIndex Method.
But I get error on compile "Unable to convert from 'Object' to 'DataCell_Class'".
How can I Return Value as DataCell_Class and not as a General Object.

In other words.. how do I translate ValueAtIndex answer from a General Object to a Specific Object Type.

Cheers..


		Method GetClassDataCellByNum:DataCell_Class(Class:ClassExtender_Class, CellNumber = 1)
		   Local TmpDataCell:DataCell_Class
		   If CountList(Class.DataCells) < CellNumber Then Return
		   Return Class.DataCells.ValueAtIndex(CellNumber - 1)
		End Method




Henri(Posted 2014) [#2]
Hello,

if object in Tlist is a custom type, you need to typecast the object like:
DataCell_Class(Class.DataCells.ValueAtIndex(CellNumber - 1))


-Henri


Hardcoal(Posted 2014) [#3]
Great! Very helpful mr Henry !