Page 1 of 1

Other problem to Ordercreate and descend

Posted: Mon Feb 07, 2022 10:54 am
by Silvio.Falconi
Many year ago I made a function to make a index temporaney into xbrowse

Image

Now I wish converte it for use with tdatabase and I have some problems

When the user slect the combox the the procedure create an Expression (cExpression)

sample : upper(code1)+name+DTOS(date)


TO create the index on oldest release I made

Code: Select all | Expand



IF! ldescend
       INDEX ON &cExpression  TAG neworder  FOR !DELETED()  MEMORY ADDITIVE
 ELSE
         INDEX ON DESCEND(&cExpression)  TAG neworder  FOR !DELETED() MEMORY ADDITIVE
   Endif



With Tdatabase oDbf

local cfor := "!Deleted()"
local bFor := "{ || " + cfor + "}"

//take the fields

cExpression:=""
IF !Empty(cField1 ) .and. !Empty(cField2 ) .and. !Empty(cField3)
cExpression:=(cCampo1 +'+'+cCampo2+'+'+cCampo3)
elseif !Empty(cField1 ) .and. !Empty(cField2 )
cExpression:=(cCampo1 +'+'+cCampo2)
elseif !Empty(cField1 )
cExpression:=(cCampo1)
Endif

//ordcreate
bCode := "{ || " + cExpression + "}"

OrdCondSet(cFor,bFor,,,,, RECNO(),,,, )
OrdCreate( , cneworder, cExpression, &bCode )


but give me an error
Workarea not in use: ORDCREATE
but if I made ?oDbf:used give me .t.
How I can resolve it ?


I tried also with

cIndexFile := "temp.cdx"
cTagName := cneworder
cIndexKey := cExpression
bIndexKey := &bCode
lUnique := .f.
lAdditive :=.t.

OrdCreate(cIndexFile ,cTagName ,cIndexKey , bIndexKey , lUnique ,lAdditive )

Re: Other problem to Ordercreate and descend

Posted: Mon Feb 07, 2022 11:02 am
by hmpaquito
Please, use:

Code: Select all | Expand

oDbf:CreateIndex(cFile, cTag, cKey, lUnique, lDescend, lMemory)


OR

Code: Select all | Expand

(oDbf:cAlias)-> ( OrdCondSet(cFor,bFor,,,,, RECNO(),,,, ) )
(oDbf:cAlias)-> ( OrdCreate( , cneworder, cExpression, &bCode ) )

Re: Other problem to Ordercreate and descend

Posted: Mon Feb 07, 2022 11:45 am
by Silvio.Falconi
hmpaquito wrote:Please, use:

Code: Select all | Expand

oDbf:CreateIndex(cFile, cTag, cKey, lUnique, lDescend, lMemory)


OR

Code: Select all | Expand

(oDbf:cAlias)-> ( OrdCondSet(cFor,bFor,,,,, RECNO(),,,, ) )
(oDbf:cAlias)-> ( OrdCreate( , cneworder, cExpression, &bCode ) )



thanks run ok

Re: Other problem to Ordercreate and descend

Posted: Mon Feb 07, 2022 12:00 pm
by karinha
You can also use:

Code: Select all | Expand


EXTERNAL DESCEND

FUNCTION ReIndexa( DeOndeVem )