Files
harbour-core/tests/asort.prg
vszakats 9687850865 2013-03-16 02:10 UTC+0100 Viktor Szakats (harbour syenar.net)
* (all files)
    * stripped svn header
    * minor cleanups
    ; use following command to find out the history of files:
       git log
       git log --follow
       git blame
       git annotate
2013-03-16 02:11:42 +01:00

65 lines
1.4 KiB
Plaintext

#ifndef __HARBOUR__
#define hb_ntos( n ) LTrim( Str( n ) )
#endif
PROCEDURE Main()
LOCAL oError := ErrorNew()
LOCAL a := { 3, 2, 1 }
LOCAL b := { 10 }
LOCAL c := { 2, .T., "B", NIL, { 1 }, {|| b }, oError, Date(), 1, .F., "A", NIL, Date() - 1, { 0 }, {|| a }, oError }
? "Original...:", aDump( a )
? "ASort......:", aDump( ASort( AClone( a ) ) )
? "ASort.block:", aDump( ASort( AClone( a ), , , {| x, y | x < y } ) )
?
? "Original...:", aDump( b )
? "ASort......:", aDump( ASort( AClone( b ) ) )
? "ASort.block:", aDump( ASort( AClone( b ), , , {| x, y | x < y } ) )
?
? "Original...:", aDump( c )
? "ASort......:", aDump( ASort( AClone( c ) ) )
? "ASort.block:", aDump( ASort( AClone( c ), , , {| x, y | xToStr( x ) < xToStr( y ) } ) )
?
RETURN
FUNCTION aDump( a )
LOCAL cStr := ""
LOCAL n := Len( a )
LOCAL i
FOR i := 1 TO n
cStr += AllTrim( xToStr( a[ i ] ) ) + " "
NEXT
RETURN cStr
FUNCTION xToStr( xValue )
LOCAL cType := ValType( xValue )
DO CASE
CASE cType == "C" .OR. cType == "M"
RETURN xValue
CASE cType == "N"
RETURN hb_ntos( xValue )
CASE cType == "D"
RETURN DToC( xValue )
CASE cType == "L"
RETURN iif( xValue, ".T.", ".F." )
CASE cType == "U"
RETURN "NIL"
CASE cType == "A"
RETURN "{.}"
CASE cType == "B"
RETURN "{|| }"
CASE cType == "O"
RETURN "[O]"
ENDCASE
RETURN xValue