FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Index with Macro on Tdatabase
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Index with Macro on Tdatabase
Posted: Thu May 12, 2022 01:44 PM
I must make a temporaney index on a field but I not Know wich I Know only the nPOS (1-5)


Code (fw): Select all Collapse
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 (fw): Select all Collapse
 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 (fw): Select all Collapse
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 (fw): Select all Collapse
 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 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: 218
Joined: Mon Feb 07, 2022 09:54 PM
Re: Index with Macro on Tdatabase
Posted: Fri May 13, 2022 08:12 AM
Hi Silvio,

you don't need the macro operator.
Just do
Code (fw): Select all Collapse
do case
   case nPos == 1
   oDbf:CreateIndex( , r1, r1, .f., .f., .t. )
   ...
endcase
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Index with Macro on Tdatabase
Posted: Fri May 13, 2022 08:25 AM
Detlef wrote:Hi Silvio,

you don't need the macro operator.
Just do
Code (fw): Select all Collapse
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 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