Page 3 of 3

Re: Bug in Harbour Descend()

PostPosted: Wed Oct 19, 2022 12:40 pm
by cnavarro
For me run OK

Image

Re: Bug in Harbour Descend()

PostPosted: Wed Oct 19, 2022 1:18 pm
by karinha
Code: Select all  Expand view

#include "Fivewin.ch"

REQUEST HB_LANG_IT
REQUEST HB_CODEPAGE_ITWIN, HB_CODEPAGE_IT850

FUNCTION MAIN()

   LOCAL cFile

   HB_CDPSELECT( "IT850" )
   HB_LANGSELECT( "IT" )

   HB_SETTERMCP( "ITWIN", "ITWIN", .T. )

   HB_CDPSELECT( "UTF8" )
   HB_SETCODEPAGE( "UTF8" )

   IF FILE( "ENRICO.txt" )

      ERASE "ENRICO.txt"

   ENDIF

   // MEMOWRIT( "ENRICO.txt", HB_OemToAnsi( "àèéìòù" ) )

   MEMOWRIT( "ENRICO.txt", "àèéìòù" )

   cFile := "ENRICO.txt"

   WinExec( "Notepad.exe " + cFile )

RETURN NIL

// fin / end
 


Regards, saludos.

Re: Bug in Harbour Descend()

PostPosted: Wed Oct 19, 2022 2:17 pm
by Enrico Maria Giordano
cnavarro wrote:For me run OK


Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    HB_SETCODEPAGE( "UTF8" )

    ? HB_MEMOWRIT( "àèéìòù.txt", "àèéìòù" )

    RETURN NIL


Result: .F., and no file written. :-(

Re: Bug in Harbour Descend()

PostPosted: Wed Oct 19, 2022 2:20 pm
by Enrico Maria Giordano
karinha wrote:
Code: Select all  Expand view
MEMOWRIT( "ENRICO.txt", "àèéìòù" )


It doesn't work with this:

Code: Select all  Expand view
MEMOWRIT( "àèéìòù.txt", "àèéìòù" )

Re: Bug in Harbour Descend()

PostPosted: Wed Oct 19, 2022 5:21 pm
by Enrico Maria Giordano
A workaroud that seems to work fine:

Code: Select all  Expand view
#include "Fivewin.ch"


REQUEST HB_CODEPAGE_ITWIN

#xtranslate DESCEND( STR( <nVal>[, <nLen>][, <nDec>] ) ) => Str( 999999999999999 - <nVal> )
#xtranslate DESCEND( DTOS( <dVal> ) ) => Str( Descend( <dVal> ) )


FUNCTION MAIN()

    LOCAL aData[ 8 ]

    LOCAL i

    HB_SETCODEPAGE( "ITWIN" )

    aData[ 1 ] = { "TEST1", 3107.77 }
    aData[ 2 ] = { "TEST2", 852.07 }
    aData[ 3 ] = { "TEST3", 191.00 }
    aData[ 4 ] = { "TEST4", 148.68 }
    aData[ 5 ] = { "TEST5", 44.73 }
    aData[ 6 ] = { "TEST6", 15.24 }
    aData[ 7 ] = { "TEST7", 255.65 }
    aData[ 8 ] = { "TEST8", 44.88 }

    ASORT( aData, , , { | aItem1, aItem2 | Descend( Str( aItem1[ 2 ], 10, 2 ) ) + aItem1[ 1 ] < Descend( Str( aItem2[ 2 ], 10, 2 ) ) + aItem2[ 1 ] } )

    FOR i = 1 TO LEN( aData )
        ? aData[ i, 1 ], aData[ i, 2 ]
    NEXT

    ? MEMOWRIT( "àèéìòù.txt", "àèéìòù" )

    RETURN NIL