Unable to convert from 'Int' to 'Int()' ?????

BlitzMax Forums/BlitzMax Programming/Unable to convert from 'Int' to 'Int()' ?????

William Drescher(Posted 2008) [#1]
Function AddToMyList(Txt$)
	Local CheckCount:Int
	
	MyList.AddLast(Txt$)
	CheckCount = MyList.Count()
	If CheckCount > 37 Then
		MyList.RemoveFirst()
	EndIf
EndFunction


When I run the code above I get the error: "Unable to convert from 'Int' to 'Int()'".

What does this mean and how can I fix it?


Gabriel(Posted 2008) [#2]
Count is a method, not a field.

CheckCount = MyList.Count()



William Drescher(Posted 2008) [#3]
That's just a typo (Note: Typo is fixed in edit). The error still occurs with the "()" there.


Yahfree(Posted 2008) [#4]
try this:

Function AddToMyList(Txt$)	
	MyList.AddLast(Txt$)
	If MyList.Count() > 37 Then
		MyList.RemoveFirst()
	EndIf
EndFunction



William Drescher(Posted 2008) [#5]
That worked, thank you


TomToad(Posted 2008) [#6]
I don't see why the code as written above wouldn't work. You should be able to assign the result of a method to a variable. So either you have:
A. A bug with BlitzMAX which needs to be hunted down and fixed
B. A problem with your program elsewhere, which still hasn't been fixed and will create weird bugs later on.

In all probability, I'd say it is B. Are you running Superstrict? That will catch a lot of bugs you might otherwise miss.

Of course, there is still the possibility that:
C. I don't really understand methods like I thought I did and you really can't assign the result to a variable.


tonyg(Posted 2008) [#7]
That first code works for me...

The actual error message matches what Gabriel posted so, maybe, Wilkua missed something before editing the original post?