Unable to convert int to object

BlitzMax Forums/BlitzMax Programming/Unable to convert int to object

supermeerkat(Posted 2005) [#1]
I've just purchased BMax (v.14) and have gotten an error I have never seen before when I use superstrict, and I try to add a number to a tlist I get the following error:

"Unable to convert int to object"

I never saw this when I used the demo version. So can I no longer add integers to tlists, or is there a way round this?


Perturbatio(Posted 2005) [#2]
well, one way I can think of, off the top of my head is to create a holding type:
Type TInt
   Field val:Int
End Type



supermeerkat(Posted 2005) [#3]
I tried the following

Strict

Local List:tlist = CreateList()

Type test
	Field t:Int
End Type

Local t:Test = New test


t.t = 30

List.AddLast t.t


And I still get the same error.


jamesmintram(Posted 2005) [#4]
Just use

List.AddLast t


skidracer(Posted 2005) [#5]
The simplest method is to use String as the container for ints in a list:
SuperStrict

Local list:tlist=New tlist

Local t:Int=40

list.addlast String(t)
list.addlast String(30)

For Local s$=EachIn list
	t=Int(s$)
	Print t
Next



rdodson41(Posted 2005) [#6]
And Int is not an object so you can make a wrapper class like Perturbatio said or put it into some other type that is an object like a string. In Java all of the basic types (int, float, boolean, etc.) have a corresponding class (Integer, Float, Boolean, etc.) that contain functions to deal with things like conversions, and they also act as a wrapper class to be used as an object.


FlameDuck(Posted 2005) [#7]
The simplest method is to use String as the container for ints in a list:
Except then they get sorted wrongly.


Perturbatio(Posted 2005) [#8]
.