FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour index on two cfields with Macro
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
index on two cfields with Macro
Posted: Fri May 10, 2013 05:27 PM

I must create index order on two field but the final user select the field

If I made INDEX ON &cCampo1 TAG NEWORDER to &cAlias run ok

If I add a new field make error

INDEX ON &cCampo1 +&cCampo2 TAG NEWORDER to &cAlias

where is the error ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: index on two cfields with Macro
Posted: Fri May 10, 2013 06:08 PM

Silvio,

Try
INDEX ON &(cCampo1 + cCampo2) TAG NEWORDER to &cAlias

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: index on two cfields with Macro
Posted: Fri May 10, 2013 09:49 PM

&(cCampo1 + cCampo2) may not work.
It might have to be &(cCampo1 +'+'+cCampo2)

Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: index on two cfields with Macro
Posted: Sat May 11, 2013 07:53 AM

thanks
Now run ok only I have problem to insert crescent or decrescent command in this line

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 195
Joined: Sun Jul 22, 2012 07:01 PM
Re: index on two cfields with Macro
Posted: Sat May 11, 2013 07:59 AM
I don't know if this would work for you but something very close to this works for me with harbour/msvc. It handles a variable number of fields, and though I haven't done it here, it is easily modified to handle other data types.

Code (fw): Select all Collapse
cIndexExpression := BuildExpression( cCampo1, cCampo2 )
INDEX ON &cIndexExpression TAG "NEWORDER" TO &cAlias

FUNCTION BuildExpression( ... )
   LOCAL i, cExpression := ""
   FOR i := 1 TO PCount()
      cExpression += hb_PValue( i )
      IF i < PCount()
         cExpression += "+"
      ENDIF
   NEXT
   RETURN cExpression
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: index on two cfields with Macro
Posted: Sat May 11, 2013 08:24 AM
THANKS
BUT HOW i CAN MAKE TO INSERT DESCENDING COMAND ?
IF I mADE
INDEX ON &(cCampo1 +'+'+cCampo2+'+'+cCampo3) TAG NEWORDER to &cAlias IT SEEMS TO RUN OK

if i MADE
INDEX ON &(cCampo1 +'+'+cCampo2+'+'+cCampo3) TAG NEWORDER to &cAlias DESCENDING

IT MAKE ERROR

Dear rhlawek your func is good but how I can to insert descending or crescent option ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: index on two cfields with Macro
Posted: Sat May 11, 2013 03:59 PM
Silvio:

Perhaps the next code can help you

Code (fw): Select all Collapse
INDEX ON DESCEND(FIELD->HDR_FOL) TAG (cIdx2) TO (cAlias) FOR ! DELETED()


BTW, I don't know why do you need a macro substitution

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: index on two cfields with Macro
Posted: Sat May 11, 2013 05:33 PM

INDEX ON DESCEND(&cExpression) TAG neworder FOR !DELETED()

THIS MAKE ERROR NOT FOUND DESCEND FUNCTION

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: index on two cfields with Macro
Posted: Sat May 11, 2013 05:56 PM
Silvio:

Try with this code in your main prg

Code (fw): Select all Collapse
REQUEST DESCEND


Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: index on two cfields with Macro
Posted: Sat May 11, 2013 07:08 PM

thanks now run

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion