Int in TList

BlitzMax Forums/BlitzMax Beginners Area/Int in TList

Vertex(Posted 2005) [#1]
How can I get int-values?
Local List:TList

List = CreateList()
List.AddLast(10)
List.AddLast(20)
List.AddLast(30)

Print List.ValueAtIndex(1)


Must be print out 20, but I can't convert from object to int :(

cu olli


Dreamora(Posted 2005) [#2]
Use explicit Typecasting


print string( List.ValueAtIndex(1) )

or for int

print int( List.ValueAtIndex(1) )


List always returns a baseobject you have to cast to the specific type.


Vertex(Posted 2005) [#3]
Local List:TList

List = CreateList()
List.AddLast(10)
List.AddLast(20)
List.AddLast(30)

Print Int(List.ValueAtIndex(1))

"Compile Error:Unable to convert from 'Object' to 'Int'"

Don't work.
cu olli


Dreamora(Posted 2005) [#4]
hmm checked the source of it.

Actually the question is if it really returns the object within.

It does "eachin self" ... and TList only consists of TLink ... so theoretically it should return a TLink.

have you tried


print int( List.ValueAtIndex(1).Value )


don't know if this works ... perhaps I don't understund what the function actually does ... in this case I'm sorry