Bug in Harbour Descend()

Re: Bug in Harbour Descend()

Postby cnavarro » Wed Oct 19, 2022 12:40 pm

For me run OK

Image
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in Harbour Descend()

Postby karinha » Wed Oct 19, 2022 1:18 pm

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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7808
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Bug in Harbour Descend()

Postby Enrico Maria Giordano » Wed Oct 19, 2022 2:17 pm

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. :-(
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Harbour Descend()

Postby Enrico Maria Giordano » Wed Oct 19, 2022 2:20 pm

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


It doesn't work with this:

Code: Select all  Expand view
MEMOWRIT( "àèéìòù.txt", "àèéìòù" )
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Harbour Descend()

Postby Enrico Maria Giordano » Wed Oct 19, 2022 5:21 pm

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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Willi Quintana and 92 guests