On Wed, 12 Nov 2008, Saulius Zrelskis wrote:

Hi Saulius,

> Sample below behaves different in Clipper and Harbour.
> Clipper:
> OrdKey: CODE
> KEYSIZE:         20
>          1 CODE: check over           ORDKEYVAL: check over
>          2 CODE: check up             ORDKEYVAL: check up
>          3 CODE: check out            ORDKEYVAL: check out
> Harbour:
> OrdKey: CODE
> KEYSIZE:          4
>          1 CODE: check over           ORDKEYVAL: chec
>          2 CODE: check up             ORDKEYVAL: chec
>          3 CODE: check out            ORDKEYVAL: chec

It's expected. CL53 DBFCDX ignores codeblock passed to ordCreate()
and recompile string key value. AFAIR few year ago I replicated it
but people reported it as problem when they are using hacked custom
codeblock with local variables for some temporary custom indexes.

> #ifdef __HARBOUR__
>   #include "dbinfo.ch"
>   request HB_GT_STD_DEFAULT
> #else
>   #include "ord.ch"
> #endif
> request DBFCDX
> #define TMP_DST "tst_dst"
> Proc Main()
>   Local nFor, cKey, aValues
>   FIELD CODE
>  aValues := { "check over", ;
>               "check up", ;
>               "check out" }
>  RddSetDefault( 'DBFCDX' )
>  dbcreate( TMP_DST, { {"CODE", "C", 20, 0} } )
>  USE TMP_DST EXCLUSIVE
> // INDEX ON CODE TAG T1
>  cKey := "CODE"
>  ordCreate(, "T1", cKey, {|| cKey} )

Here is a bug in your code which creates the difference. It should be:
   ordCreate(, "T1", cKey, {|| &cKey} )
otherwise you create index where key value is fixed "CODE" string in
the given codeblock. CL53 DBFCDX/COMIX ignores codeblock but CL52 DBFCDX/
SIX3 and DBFNTX doesn't and the results are exactly the same as in Harbour.

>  SET INDEX TO (TMP_DST)

This closes current index and reopen it. Because in index file only string
representation of used expressions can be stored (codeblocks cannot) then
"CODE" expression is recompiled and now it's used instead of fixed string
"CODE". But index was created with key size 4 and this information is
stored in index file and is properly retrieve.

best regards,
Przemek
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to