..list sort issue..

BlitzMax Forums/BlitzMax Programming/..list sort issue..

Naughty Alien(Posted 2009) [#1]
..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





N(Posted 2009) [#2]
There is no way I'm going to try to figure out what is wrong with that block of unformatted code...


therevills(Posted 2009) [#3]
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.


Naughty Alien(Posted 2009) [#4]
..oh boy...yup..yup..yupp.. thanks therevills ;)


therevills(Posted 2009) [#5]
No problem, Naughty Alien, glad to help...


ImaginaryHuman(Posted 2009) [#6]
"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()