..list sort issue..
BlitzMax Forums/BlitzMax Programming/..list sort issue..
| ||
..hi guys..I would like to know, why SuperStrict causing this code doesnt work, while without superstrict working just fine...I need to sort some Lists for my clouds system processing, but im getting "Function can not return a value' error .. EDIT.. I guess its readable now.. 'SuperStrict Global s:Unit Type Unit Global unitlist:TList=CreateList() Field X:Float,Y:Float Field Number:Int Method New() Number=Rand(10) ListAddLast UnitList,Self End Method Method compare(myobject:Object) s:Unit = Unit(myobject) If Not s Then Return 1 Return number - s.number End Method End Type SeedRnd MilliSecs() For Local x% = 1 To 10 Local my:Unit = New unit Next SortList unit.unitlist ' Check to see if it is sorted correctly For s:unit = EachIn unit.unitlist Print s.number Next |
| ||
There is no way I'm going to try to figure out what is wrong with that block of unformatted code... |
| ||
SuperStrict Global s:Unit Type Unit Global unitlist:TList=CreateList() Field X:Float,Y:Float Field Number:Int Method New() Number=Rand(10) ListAddLast UnitList,Self End Method Method compare:Int(myobject:Object) s:Unit = Unit(myobject) If Not s Then Return 1 Return number - s.number End Method End Type SeedRnd MilliSecs() For Local x% = 1 To 10 Local my:Unit = New unit Next SortList unit.unitlist ' Check to see if it is sorted correctly For s:unit = EachIn unit.unitlist Print s.number Next When using SuperStrict and when using return, you must have a return type. Just add :int to compare and it works fine. |
| ||
..oh boy...yup..yup..yupp.. thanks therevills ;) |
| ||
No problem, Naughty Alien, glad to help... |
| ||
"Function can not return a value" means you are trying to do `Return Value` but you haven't set up your function with a return type e.g. Function MyFunc:Int() |