Página 1 de 1

indexando com descend

Enviado: 12 Mai 2021 07:36
por juniorcamilo
Ola amigos.

estou com um problema de índice usando o descend!
resumindo o código:

Código: Selecionar todos

         if use_arqex5("ARQAUD01","AUDITOR",,"DBFCDX","1") == .f.
            AUD->( __DBpack() )
 	        Ferase('IAUDIT01.CDX')
      	   Index on descend(dtos(DATA)+HORA) tag TAG1 to IAUDIT01
            AUDITOR->(Dbclosearea())
         endif
pelo sistema reorganizo assim e não fica em ordem, mas no dbu32 sim!
segue em anexo o arquivo e o índice gerado por minha aplicação e o índice gerado pelo dbu32!
xharbour 1.2.3!

indexando com descend

Enviado: 12 Mai 2021 07:49
por paiva_dbdc
BOM dia

tente separar descend(dtod... + descend(hora)


uso MUITO o descend (dtos(data)) + outros campos ....

Paiva

indexando com descend

Enviado: 12 Mai 2021 08:21
por juniorcamilo
paiva_dbdc escreveu: tente separar descend(dtod... + descend(hora)
Paiva
sem sucesso! mesma coisa!

indexando com descend

Enviado: 12 Mai 2021 09:34
por JoséQuintas
Se fosse Windows estariam falando muito mal disso.

Opção 1: Considere bug no Harbour, por manter compatibilidade com Clipper

Opção 2: Considere uso errado

Soluções:

a) use a cláusula DESCEND, NÃO a função Descend():
INDEX ON Dtos(DATA) + HORA DESCEND
Desta forma, nada precisa ser convertido

b) Crie uma função cpDescend() alternativa pra respeitar a codepage
Aonde a opção anterior não puder resolver

indexando com descend

Enviado: 12 Mai 2021 10:02
por Itamar M. Lins Jr.
Olá!
Eu uso assim:

Código: Selecionar todos

   index on dtos(entrada)      tag os06 to servicos.cdx  descending eval {||oBar:Set(,Recno()),.t.}
Saudações,
Itamar M. Lins Jr.

indexando com descend

Enviado: 12 Mai 2021 10:27
por juniorcamilo
Itamar M. Lins Jr. escreveu:Olá!
Eu uso assim:

Código: Selecionar todos

   index on dtos(entrada)      tag os06 to servicos.cdx  descending eval {||oBar:Set(,Recno()),.t.}
Saudações,
Itamar M. Lins Jr.
Obrigado Itamar! funcionou perfeitamente!

testei também a alternativa do Quintas(não funcionou)!
desta forma:
INDEX ON Dtos(DATA) + HORA DESCEND

indexando com descend

Enviado: 12 Mai 2021 11:43
por JoséQuintas
Errei na hora de mostrar.
Mas os CH sempre tiram a dúvida.

ord.ch

Código: Selecionar todos

#ifdef HB_COMPAT_C53

#xtranslate ORDCOND( [FOR <for>]                             ;
                     [<all:ALL>] [WHILE <while>]             ;
                     [EVAL <eval>] [EVERY <every>]           ;
                     [RECORD <rec>] [NEXT <next>]            ;
                     [<rest:REST>] [<descend: DESCENDING>] ) ;
      => ordCondSet( <"for">, <{for}>,                       ;
                     [<.all.>], <{while}>,                   ;
                     <{eval}>, <every>,                      ;
                     RecNo(), <next>, <rec>,                 ;
                     [<.rest.>], [<.descend.>] )

#endif

indexando com descend

Enviado: 12 Mai 2021 21:24
por Kapiaba

Código: Selecionar todos

/*
<alias>->( OrdDescend( ,,.T. ) ) //<- DESCENDING
<alias>->( OrdDescend( ,,.F. ) ) //<- sem DESCENDING

*/

EXTERNAL DESCEND

FUNCTION Main()

   FIELD LAST, First

   USE Customer

   INDEX ON Upper( Last + First ) TO Cust01

   GO TOP

   ? LAST               // result: Alberts

   GO BOTTOM

   ? LAST               // result: Waters

   OrdDescend( , , .T. )     // change navigational order

   SKIP - 1                  // skipping backwards from the last

   // record hits begin of file.
   ? Bof()                  // result: .T.

   GO BOTTOM
   ? Eof()                  // result: .F.
   ? LAST               // result: Alberts

   SKIP

   ? Eof()                  // Result: .T.

   GO TOP

   ? LAST               // result: Waters

   BROWSE()

   USE

RETURN NIL

// ISTO NAO FUNCIONA EM XHARBOUR
/*
SET DESCENDING
Change the descending flag of the controlling order

Syntax

      SET DESCENDING ON | OFF | (<lToggle>)
Arguments

ON enables the descending flag.

OFF disables the descending flag.

<lToggle> is a logical expression that must be enclosed in parentheses. A value of true (.T.) is the same as ON, and a value of false (.F.) is the same as OFF.

Note

The initial default of this setting depends on whether the controlling order was created with DESCENDING as an attribute.

Description

SET DESCENDING is functionally equivalent to ORDDESCEND(). Refer to this function for more information.

Examples

      .  The following example illustrates SET DESCENDING.  every order
        can be both ascending and descending:

      USE Customer VIA "DBFCDX"
      INDEX ON LastName TAG Last
      INDEX ON FirstName TAG First DESCENDING

      SET ORDER TO TAG Last
      // last was originally created in ascending order

      // Swap it to descending
      SET DESCENDING ON
      // Last will now be processed in descending order

      SET ORDER TO TAG First
      // First was originally created in descending order

      // Swap it to ascending
      SET DESCENDING OFF
      // First will now be processed in ascending order
Sealso

ORDDESCEND()
*/

om dia, João na tela abaixo queria que a ordem do numero da proposta fosse alterada para decrescente, ou seja que na primeira tela fique sempre o ultimo cadastro feito.

OrdDescend( ,, .T. ) // indice em ordem crescente

OrdDescend( ,, .F. ) // indice em ordem decrescente


      USE Customer VIA "DBFCDX"
      INDEX ON LastName TAG Last
      INDEX ON FirstName TAG First DESCENDING

      SET ORDER TO TAG Last
      // last was originally created in ascending order

      // Swap it to descending
      SET DESCENDING ON
      // Last will now be processed in descending order

      SET ORDER TO TAG First
      // First was originally created in descending order

      // Swap it to ascending
      SET DESCENDING OFF
      // First will now be processed in ascending order

       USE o cliente VIA "DBFCDX"
       INDEX ON LastName TAG Last
       INDEX ON FirstName TAG First DESCENDING

       SET ORDER TO TAG Último
       // last foi originalmente criado em ordem crescente

       // Troque para descendente
       SET DESCENDING ON
       // A última será processada agora em ordem descendente

       SET ORDER TO TAG Primeiro
       // Primeiro foi originalmente criado em ordem decrescente

       // Troque para ascendente
       SET DESCENDING OFF
       // Primeiro será processado em ordem crescente