Bug in Harbour Descend()

Re: Bug in Harbour Descend()

Postby karinha » Mon Oct 17, 2022 2:19 pm

Master Enrico, look this:

http://www.pctoledo.com.br/forum/viewtopic.php?f=4&t=19895

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7834
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Bug in Harbour Descend()

Postby Enrico Maria Giordano » Mon Oct 17, 2022 2:50 pm

Ok, thank you. I already use that workaround. I was hope that there is a better way.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Harbour Descend()

Postby Enrico Maria Giordano » Tue Oct 18, 2022 3:23 pm

Please note that this is not working too:

Code: Select all  Expand view  RUN
DESCEND( DTOS( dDate ) )


I can't believe that this bug has not been corrected yet... :-(
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Harbour Descend()

Postby karinha » Tue Oct 18, 2022 5:05 pm

Master Enrico, I'm not sure, but I think you have to save the DATES, in a Database first. Just an idea.

Maestro Enrico, no estoy seguro, pero creo que primero debe guardar las FECHAS en una base de datos. Solo una idea.

Example / ejemplo:

Code: Select all  Expand view  RUN

    USE Sales NEW
    INDEX ON Str(Descend(SaleDate)) + Salesman TO LastSale
OR

   USE Sales NEW
   INDEX ON Descend(OrdDate) TO SalesDate
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7834
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Bug in Harbour Descend()

Postby Enrico Maria Giordano » Tue Oct 18, 2022 5:16 pm

It doesn't work either. This works:

Code: Select all  Expand view  RUN
DESCEND( dDate )


But this not:

Code: Select all  Expand view  RUN
DESCEND( DTOS( dDate ) )


Please note that there is no problem at all with xHarbour.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Harbour Descend()

Postby karinha » Tue Oct 18, 2022 5:36 pm

? DESCEND( dDate ) // Esto me retorna un numero, está correcto?

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7834
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Bug in Harbour Descend()

Postby Enrico Maria Giordano » Tue Oct 18, 2022 5:42 pm

Yes, that's right. The problem is there when you want to combine dates and other data types. In this case you have to convert the dates to strings and here the codepage breaks the sort order of the descending string.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Harbour Descend()

Postby karinha » Tue Oct 18, 2022 5:45 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7834
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Bug in Harbour Descend()

Postby Enrico Maria Giordano » Tue Oct 18, 2022 6:04 pm

Thank you. It is not a real solution but better than nothing:

Code: Select all  Expand view  RUN
DESCEND( STR( nVal ) ) => STR( 999999999999999 - nVal )
DESCEND( DTOS( dVal ) ) => STR( DESCEND( dVal ) )


Let's hope that Harbour developers will fix the bug, one day or another...

My concern is that Descend() could be called millions of times during a sort. So it should be as faster as possible.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Harbour Descend()

Postby cnavarro » Tue Oct 18, 2022 6:23 pm

From Harbour-users group
DESCEND() function is designed to operate on binary (BYTE) sorting
and gives reverted collation order only for codepages which use
such collation.

Because DESCEND() converts numbers to characters which have
special order in CP you are using. Look at this list archive
for some easy to create custom DESCEND() replacements which
can be used with non accented Latin based languages like
Lithuanian or Polish ones.


Dear Enrico
Please try with this. I hope you find this codepage useful
Code: Select all  Expand view  RUN

REQUEST HB_LANG_IT
REQUEST HB_CODEPAGE_ITWIN, HB_CODEPAGE_IT850

HB_CDPSELECT( "IT850" )
hb_langSelect( 'IT' )
// hb_SetTermCP( 'ITWIN', 'ITWIN', .T. )   // Also with it run ok
 
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: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in Harbour Descend()

Postby Enrico Maria Giordano » Tue Oct 18, 2022 9:24 pm

It doesn't work, it creates a file with the wrong name. Please try this:

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


REQUEST HB_LANG_IT
REQUEST HB_CODEPAGE_ITWIN, HB_CODEPAGE_IT850


FUNCTION MAIN()

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

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

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

    RETURN NIL
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Harbour Descend()

Postby cnavarro » Wed Oct 19, 2022 12:52 am

Enrico Maria Giordano wrote:It doesn't work, it creates a file with the wrong name. Please try this:

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


REQUEST HB_LANG_IT
REQUEST HB_CODEPAGE_ITWIN, HB_CODEPAGE_IT850


FUNCTION MAIN()

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

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

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

    RETURN NIL


Sorry Enrico, but the example you put now has nothing to do with the Descend() function
Has the example I posted worked?
I will look at the new example you propose and I will answer you
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: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in Harbour Descend()

Postby Enrico Maria Giordano » Wed Oct 19, 2022 7:52 am

The problem is: without any codepage settings (ie. EN codepage) Descend() is fine but accented chars from filesystem are wrong. With ITWIN (or other codepages I tried) the accented chars from filesystem are right but Descend() is not working.

Any solutions will make me happy. :-)
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Harbour Descend()

Postby cnavarro » Wed Oct 19, 2022 8:06 am

Enrico Maria Giordano wrote:The problem is: without any codepage settings (ie. EN codepage) Descend() is fine but accented chars from filesystem are wrong. With ITWIN (or other codepages I tried) the accented chars from filesystem are right but Descend() is not working.

Any solutions will make me happy. :-)


This is more simple

Code: Select all  Expand view  RUN


#include "Fivewin.ch"

FUNCTION MAIN()

    LOCAL aData[ 7 ]

    LOCAL i


    HB_SETCODEPAGE( "UTF8" )

    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 }

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

    xBrowse( aData )

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


    RETURN NIL

 
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: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bug in Harbour Descend()

Postby Enrico Maria Giordano » Wed Oct 19, 2022 8:26 am

Sorry, it doesn't work:

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


Result:

Code: Select all  Expand view  RUN
.F.


:-(
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 58 guests