Index with Macro on Tdatabase

Index with Macro on Tdatabase

Postby Silvio.Falconi » Thu May 12, 2022 1:44 pm

I must make a temporaney index on a field but I not Know wich I Know only the nPOS (1-5)


Code: Select all  Expand view


do case
 case nWheel = 1
         r1:= "BA1"
         r2:= "BA2"
         r3:= "BA3"
         r4:= "BA4"
         r5:= "BA5"
case .....
Endcase

oDbf:= TDatabase():Open( , cDir+"demo", "DBFCDX", .T. )
                    Do case
                     Case nPos=1
                        oDbf:CreateIndex( , , oDbf:&r1, .f., .f., .t. )
                      Case nPos=2
                       oDbf:CreateIndex( , , oDbf:&r2, .f., .f., .t. )
                      Case nPos=3
                       oDbf:CreateIndex( , , oDbf:&r3, .f., .f., .t. )
                      Case nPos=4
                       oDbf:CreateIndex( , , oDbf:&r4, .f., .f., .t. )
                      Case nPos=5
                       oDbf:CreateIndex( , , oDbf:&r5, .f., .f., .t. )
                    Endcase

 oDbf:gotop()

 


Why not run and make error ?

why make error ?

I tried also with
Code: Select all  Expand view
oDbf:= TDatabase():Open( , cDir+"demo", "DBFCDX", .T. )
           
                    Do case
                    Case nPos=1
                       oDbf:CreateIndex( cDir+"demo", "TMP", oDbf:&r1, .f., .f., .t. )
                    Case nPos=2
                        oDbf:CreateIndex( cDir+"demo", "TMP", oDbf:&r2, .f., .f., .t. )
                      Case nPos=3
                        oDbf:CreateIndex( cDir+"demo", "TMP", oDbf:&r3, .f., .f., .t. )
                      Case nPos=4
                       oDbf:CreateIndex( cDir+"demo", "TMP", oDbf:&r4, .f., .f., .t. )
                      Case nPos=5
                       oDbf:CreateIndex( cDir+"demo", "TMP", oDbf:&r5, .f., .f., .t. )
                    Endcase

           
             oDbf:gotop()
 


make this error


Code: Select all  Expand view
Error description: Error BASE/1081  Parametro errato: +
   Args:
     [   1] = C   {||
     [   2] = N   0

Stack Calls
===========
   Called from: .\source\classes\DATABASE.PRG => COMPILE( 1293 )
   Called from: .\source\classes\DATABASE.PRG => TDATABASE:TD_CREATEINDEX( 2439 )
   Called from: .\source\classes\DATABASE.PRG => (b)TDATABASE( 135 )
   Called from: .\source\classes\DATABASE.PRG => TDATABASE:CREATEINDEX( 0 )



i tried also with

Code: Select all  Expand view
Do case
                    Case nPos=1
                      cNewIndex :=oFrequenti:&r1
                    Case nPos=2
                       cNewIndex :=oFrequenti:&r2
                    Case nPos=3
                       cNewIndex :=oFrequenti:&r3
                    Case nPos=4
                       cNewIndex :=oFrequenti:&r4
                    Case nPos=5
                        cNewIndex :=oFrequenti:&r5
                     Endcase

       oFrequenti:CreateIndex( "demo", "TMP", cNewIndex, .f., .f., .t. )
 


same error

Any help pls
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Index with Macro on Tdatabase

Postby Detlef » Fri May 13, 2022 8:12 am

Hi Silvio,

you don't need the macro operator.
Just do
Code: Select all  Expand view
do case
   case nPos == 1
   oDbf:CreateIndex( , r1, r1, .f., .f., .t. )
   ...
endcase 
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: Index with Macro on Tdatabase

Postby Silvio.Falconi » Fri May 13, 2022 8:25 am

Detlef wrote:Hi Silvio,

you don't need the macro operator.
Just do
Code: Select all  Expand view
do case
   case nPos == 1
   oDbf:CreateIndex( , r1, r1, .f., .f., .t. )
   ...
endcase 


thanks
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 88 guests