index on two cfields with Macro

index on two cfields with Macro

Postby Silvio.Falconi » Fri May 10, 2013 5: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: index on two cfields with Macro

Postby Marc Vanzegbroeck » Fri May 10, 2013 6: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
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: index on two cfields with Macro

Postby Gale FORd » Fri May 10, 2013 9:49 pm

&(cCampo1 + cCampo2) may not work.
It might have to be &(cCampo1 +'+'+cCampo2)
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: index on two cfields with Macro

Postby Silvio.Falconi » Sat May 11, 2013 7: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: index on two cfields with Macro

Postby rhlawek » Sat May 11, 2013 7: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: Select all  Expand view

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
 
User avatar
rhlawek
 
Posts: 194
Joined: Sun Jul 22, 2012 7:01 pm

Re: index on two cfields with Macro

Postby Silvio.Falconi » Sat May 11, 2013 8: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: index on two cfields with Macro

Postby Armando » Sat May 11, 2013 3:59 pm

Silvio:

Perhaps the next code can help you

Code: Select all  Expand view

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
User avatar
Armando
 
Posts: 3223
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: index on two cfields with Macro

Postby Silvio.Falconi » Sat May 11, 2013 5: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: index on two cfields with Macro

Postby Armando » Sat May 11, 2013 5:56 pm

Silvio:

Try with this code in your main prg

Code: Select all  Expand view

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
User avatar
Armando
 
Posts: 3223
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: index on two cfields with Macro

Postby Silvio.Falconi » Sat May 11, 2013 7:08 pm

thanks now run
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 62 guests