Unable to convert from 'Int' to 'Int()' ?????
BlitzMax Forums/BlitzMax Programming/Unable to convert from 'Int' to 'Int()' ?????
| ||
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? |
| ||
Count is a method, not a field.CheckCount = MyList.Count() |
| ||
That's just a typo (Note: Typo is fixed in edit). The error still occurs with the "()" there. |
| ||
try this:Function AddToMyList(Txt$) MyList.AddLast(Txt$) If MyList.Count() > 37 Then MyList.RemoveFirst() EndIf EndFunction |
| ||
That worked, thank you |
| ||
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. |
| ||
That first code works for me... The actual error message matches what Gabriel posted so, maybe, Wilkua missed something before editing the original post? |