problem with dbUseArea - resolved -

problem with dbUseArea - resolved -

Postby Silvio.Falconi » Thu Apr 13, 2023 9:18 am

DbUseArea( .F. ,"DBFCDX", ::aIdx[ i, 1 ],, .F. ) // not work


Error
Code: Select all  Expand view  RUN

   Time from start: 0 hours 0 mins 1 secs
   Error occurred at: 04/13/23, 11:21:28
   Error description: Error BASE/1068  Argument error: array access
   Args:
     [   1] = U  
     [   2] = N   1

Stack Calls
===========
   Called from: ut_reindex.PRG => TINDICE:ORDER( 108

 


Line 108 DbUseArea( .F. ,"DBFCDX", ::aIdx[ i, 1 ],, .F. )

I'm using a small class to index dbf files on my app

on test I use customer.dbf
Code: Select all  Expand view  RUN


#include 'fivewin.ch'
#include "constant.ch"
#INCLUDE "DIRECTRY.CH"

REQUEST DBFCDX

*MEMVAR oApp

Function Main()
   local cPathDbf:=".\data\"
    TIndice():New(cPathDbf):Activate()
    return nil


CLASS TIndice
   DATA aIdx
   DATA nIdx
   DATA oDlg
   DATA oFont
   DATA oMeter
   DATA cText
   DATA oSay
   DATA oAnimate
   DATA oBmp
   DATA oBtnok
   DATA oBtnExit
   DATA cPathDbf

   METHOD New() CONSTRUCTOR
   METHOD Activate()
   METHOD Order()
   END CLASS


METHOD New(cPathDbf) CLASS TIndice
   

   //test for  demo
   ::aIdx  := { ;
      { "
CUSTOMER" , { { "Upper(First)"                    , "First"  , "Customer"  }     ,;
                       { "
Upper(Last)"                     , "Last"   , "Customer"  }     ,;
                       { "
State"                           , "State"  , "Customer"  } } } ,;
                     }


  // ::cPathDbf  := cPathDbf

RETURN Self


METHOD Activate() CLASS TIndice
   LOCAL QSelf := Self

      local nBottomDlg   := 10
      local nRightDlg    := 40
      local nWd       := Max( nRightDlg * DLG_CHARPIX_W, 180 )
      local nHt       := nBottomDlg * DLG_CHARPIX_H

      ::oFont:= TFont():New( "
Tahoma", 0, 12,, )

   DEFINE DIALOG ::oDlg SIZE nWd, nHt PIXEL TRUEPIXEL  ;
        STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                  WS_MINIMIZEBOX)

   SET FONT TO ::oFont OF ::oDlg

    @ 2,12 SAY ::oSay PROMPT ::cText SIZE 200,20  OF  ::oDlg  COLOR CLR_RED UPDATE

   ::oMeter  := TProgress():New( 4.8, 2, ::oDlg, , , , .f.,, 300, 15, "
", .f., .f. )
   ::oMeter:SetRange( 0, LEN( ::aIdx ) )
   ::oAnimate := TAnimate():New( 2.8, 2,  ::oDlg, .t., , 200, 12)

   @ 110,10  BUTTON ::oBtnOK Prompt "
Conferma" SIZE 55,20 PIXEL OF ::oDlg  ACTION ( ::Order() )
   @ 110,95  BUTTON ::oBtnExit Prompt "
Annulla"  SIZE 55,20 PIXEL OF ::oDlg  ACTION ( ::oDlg:End() )

   ACTIVATE DIALOG ::oDlg CENTERED;
         ON INIT ( QSelf:oAnimate:CopyFile(), QSelf:oAnimate:Play() )
RETURN NIL


METHOD Order() CLASS TIndice
   LOCAL i
   LOCAL k
   LOCAL bCode

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

   ::oBtnOk:Disable()
   ::oBtnExit:Disable()


   *xbrowser ::aIdx

   FOR i := 1 TO LEN( ::aIdx )
     //dbUseArea( .t., ::cDriver, ::cFile, ::cAlias, ::lShared, ::lReadOnly )
       DbUseArea( .F. ,"
DBFCDX", ::aIdx[ i, 1 ],, .F. )

      FOR k := 1 TO LEN( ::aIdx[ i, 2 ] )

         bCode := "
{ || " + ::aIdx[ i, 2, k, 1 ] + "}"

         OrdCondSet(cFor,bFor,,,,, RECNO(),,,, )
         OrdCreate( ::aIdx[ i, 2, k, 3 ], ::aIdx[ i, 2, k, 2 ], ::aIdx[ i, 2, k, 1 ], &bCode )

      NEXT

      DbCloseArea()

      ::oMeter:nPosition := ( ( i * 100 ) / Len( ::aIdx ) )

   NEXT

   ::oBtnExit:Enable()

   MsgInfo( "
Azione terminata", "Index" )

   ::oDlg:End()

RETURN NIL



make error , but the procedure create the index good ...
How I can resolve ?
Last edited by Silvio.Falconi on Tue Apr 18, 2023 10:40 am, edited 1 time in total.
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: 7066
Joined: Thu Oct 18, 2012 7:17 pm

Re: problem with dbUseArea

Postby Silvio.Falconi » Fri Apr 14, 2023 9:04 am

any solution ?
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: 7066
Joined: Thu Oct 18, 2012 7:17 pm

Re: problem with dbUseArea

Postby Antonio Linares » Fri Apr 14, 2023 9:07 am

Dear Silvio,

param i seems to be nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42117
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: problem with dbUseArea

Postby Silvio.Falconi » Fri Apr 14, 2023 10:59 am

Antonio Linares wrote:Dear Silvio,

param i seems to be nil


ok but How I can resolve ?
there is for i:= 1 to...

If i>LEN( ::aIdx )
exit
endif

I not understood before it run ok , now suddenly I went to recompile and it doesn't work how is it possible ?
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: 7066
Joined: Thu Oct 18, 2012 7:17 pm

Re: problem with dbUseArea

Postby Jimmy » Fri Apr 14, 2023 12:04 pm

hi Silvio,

have you try a Macro ?
Code: Select all  Expand view  RUN
  xName := ::aIdx[ i, 1 ]
   DbUseArea( .F. ,"DBFCDX", &(xName),, .F. )
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: problem with dbUseArea

Postby Silvio.Falconi » Fri Apr 14, 2023 12:57 pm

Jimmy wrote:hi Silvio,

have you try a Macro ?
Code: Select all  Expand view  RUN
  xName := ::aIdx[ i, 1 ]
   DbUseArea( .F. ,"DBFCDX", &(xName),, .F. )

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

Re: problem with dbUseArea

Postby alerchster » Fri Apr 14, 2023 2:37 pm

Hi

The error comes from :: aIdx -> Len (::aIdx) result 2

This code works :-)

Code: Select all  Expand view  RUN


#include 'fivewin.ch'
#include "constant.ch"
#INCLUDE "DIRECTRY.CH"

REQUEST DBFCDX

*MEMVAR oApp

Function Main()
   local cPathDbf:=".\data\"
    TIndice():New(cPathDbf):Activate()
    return nil


CLASS TIndice
   DATA aIdx
   DATA nIdx
   DATA oDlg
   DATA oFont
   DATA oMeter
   DATA cText
   DATA oSay
   DATA oAnimate
   DATA oBmp
   DATA oBtnok
   DATA oBtnExit
   DATA cPathDbf

   METHOD New() CONSTRUCTOR
   METHOD Activate()
   METHOD Order()
   END CLASS


METHOD New(cPathDbf) CLASS TIndice
   

   //test for  demo

  ::aIdx  := { ;
      { "
CUSTOMER" , { { "Upper(First)"                    , "First"  , "Customer"  }     ,;
                       { "
Upper(Last)"                     , "Last"   , "Customer"  }     ,;
                       { "
State"                           , "State"  , "Customer"  } } } ,;
                     }


  // ::cPathDbf  := cPathDbf

RETURN Self


METHOD Activate() CLASS TIndice
   LOCAL QSelf := Self

      local nBottomDlg   := 10
      local nRightDlg    := 40
      local nWd       := Max( nRightDlg * DLG_CHARPIX_W, 180 )
      local nHt       := nBottomDlg * DLG_CHARPIX_H

      ::oFont:= TFont():New( "
Tahoma", 0, 12,, )

   DEFINE DIALOG ::oDlg SIZE nWd, nHt PIXEL TRUEPIXEL  ;
        STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                  WS_MINIMIZEBOX)

   SET FONT TO ::oFont OF ::oDlg

    @ 2,12 SAY ::oSay PROMPT ::cText SIZE 200,20  OF  ::oDlg  COLOR CLR_RED UPDATE

   ::oMeter  := TProgress():New( 4.8, 2, ::oDlg, , , , .f.,, 300, 15, "
", .f., .f. )
   ::oMeter:SetRange( 0, LEN( ::aIdx ) )
   ::oAnimate := TAnimate():New( 2.8, 2,  ::oDlg, .t., , 200, 12)

   @ 110,10  BUTTON ::oBtnOK Prompt "
Conferma" SIZE 55,20 PIXEL OF ::oDlg  ACTION ( ::Order() )
   @ 110,95  BUTTON ::oBtnExit Prompt "
Annulla"  SIZE 55,20 PIXEL OF ::oDlg  ACTION ( ::oDlg:End() )

   ACTIVATE DIALOG ::oDlg CENTERED;
         ON INIT ( QSelf:oAnimate:CopyFile(), QSelf:oAnimate:Play() )
RETURN NIL


METHOD Order() CLASS TIndice
   LOCAL i
   LOCAL k
   LOCAL bCode

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

   ::oBtnOk:Disable()
   ::oBtnExit:Disable()


   *xbrowser ::aIdx

   FOR i := 1 TO LEN( ::aIdx )-1                                                                                 // NEW is -1
      //dbUseArea( .t., ::cDriver, ::cFile, ::cAlias, ::lShared, ::lReadOnly )
      DbUseArea( .F. ,"
DBFCDX", ::aIdx[ i, 1 ],, .F. )

      FOR k := 1 TO LEN( ::aIdx[ i, 2 ] )

         bCode := "
{ || " + ::aIdx[ i, 2, k, 1 ] + "}"

         OrdCondSet(cFor,bFor,,,,, RECNO(),,,, )
         OrdCreate( ::aIdx[ i, 2, k, 3 ], ::aIdx[ i, 2, k, 2 ], ::aIdx[ i, 2, k, 1 ], &bCode )

      NEXT

      DbCloseArea()

      ::oMeter:nPosition := ( ( i * 100 ) / Len( ::aIdx ) )

   NEXT

   ::oBtnExit:Enable()

   MsgInfo( "
Azione terminata", "Index" )

   ::oDlg:End()

RETURN NIL
Regards

Ing. Anton Lerchster
User avatar
alerchster
 
Posts: 94
Joined: Mon Oct 22, 2012 4:43 pm

Re: problem with dbUseArea

Postby alerchster » Sat Apr 15, 2023 5:23 am

Code: Select all  Expand view  RUN


#include 'fivewin.ch'
#include "constant.ch"
#INCLUDE "DIRECTRY.CH"

REQUEST DBFCDX

*MEMVAR oApp

Function Main()
   local cPathDbf:=".\data\"
    TIndice():New(cPathDbf):Activate()
    //TIndice():Activate()
     return nil


CLASS TIndice
   DATA aIdx
   DATA nIdx
   DATA oDlg
   DATA oFont
   DATA oMeter
   DATA cText
   DATA oSay
   DATA oAnimate
   DATA oBmp
   DATA oBtnok
   DATA oBtnExit
   DATA cPathDbf

   METHOD New() CONSTRUCTOR
   METHOD Activate()
   METHOD Order()
   END CLASS


METHOD New(cPathDbf) CLASS TIndice
   

   //test for  demo
/*
  ::aIdx  := { ;
      { "
CUSTOMER" , { { "Upper(First)"                    , "First"  , "Customer"  }     ,;
                       { "
Upper(Last)"                     , "Last"   , "Customer"  }     ,;
                       { "
State"                           , "State"  , "Customer"  } } } ,;
                     }
*/
  ::aIdx  :=  { ;
      { "
CUSTOMER" , { { "Upper(First)"                    , "First"  , "Customer"  }     ,;
                       { "
Upper(Last)"                     , "Last"   , "Customer"  }     ,;
                       { "
State"                           , "State"  , "Customer"  } } } ;
                     }

//xbrowser(::aIdx)
 
  // ::cPathDbf  := cPathDbf

RETURN Self


METHOD Activate() CLASS TIndice
   LOCAL QSelf := Self

      local nBottomDlg   := 10
      local nRightDlg    := 40
      local nWd       := Max( nRightDlg * DLG_CHARPIX_W, 180 )
      local nHt       := nBottomDlg * DLG_CHARPIX_H

      ::oFont:= TFont():New( "
Tahoma", 0, 12,, )

   DEFINE DIALOG ::oDlg SIZE nWd, nHt PIXEL TRUEPIXEL  ;
        STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                  WS_MINIMIZEBOX)

   SET FONT TO ::oFont OF ::oDlg

    @ 2,12 SAY ::oSay PROMPT ::cText SIZE 200,20  OF  ::oDlg  COLOR CLR_RED UPDATE

   ::oMeter  := TProgress():New( 4.8, 2, ::oDlg, , , , .f.,, 300, 15, "
", .f., .f. )
   ::oMeter:SetRange( 0, LEN( ::aIdx ) )
   ::oAnimate := TAnimate():New( 2.8, 2,  ::oDlg, .t., , 200, 12)

   @ 110,10  BUTTON ::oBtnOK Prompt "
Conferma" SIZE 55,20 PIXEL OF ::oDlg  ACTION ( ::Order() )
   @ 110,95  BUTTON ::oBtnExit Prompt "
Annulla"  SIZE 55,20 PIXEL OF ::oDlg  ACTION ( ::oDlg:End() )

   ACTIVATE DIALOG ::oDlg CENTERED;
         ON INIT ( QSelf:oAnimate:CopyFile(), QSelf:oAnimate:Play() )
RETURN NIL


METHOD Order() CLASS TIndice
   LOCAL i
   LOCAL k
   LOCAL bCode

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

   ::oBtnOk:Disable()
   ::oBtnExit:Disable()


//   xbrowser ::aIdx

   FOR i := 1 TO LEN( ::aIdx )
     //dbUseArea( .t., ::cDriver, ::cFile, ::cAlias, ::lShared, ::lReadOnly )
      DbUseArea( .F. ,"
DBFCDX", ::aIdx[ i, 1 ],, .F. )

      FOR k := 1 TO LEN( ::aIdx[ i, 2 ] )

         bCode := "
{ || " + ::aIdx[ i, 2, k, 1 ] + "}"

         OrdCondSet(cFor,bFor,,,,, RECNO(),,,, )
         OrdCreate( ::aIdx[ i, 2, k, 3 ], ::aIdx[ i, 2, k, 2 ], ::aIdx[ i, 2, k, 1 ], &bCode )

      NEXT

      DbCloseArea()

      ::oMeter:nPosition := ( ( i * 100 ) / Len( ::aIdx ) )
   NEXT

   ::oBtnExit:Enable()

   MsgInfo( "
Azione terminata", "Index" )

   ::oDlg:End()

RETURN NIL
Regards

Ing. Anton Lerchster
User avatar
alerchster
 
Posts: 94
Joined: Mon Oct 22, 2012 4:43 pm

Re: problem with dbUseArea

Postby Silvio.Falconi » Sun Apr 16, 2023 2:42 pm

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

Re: problem with dbUseArea

Postby alerchster » Sun Apr 16, 2023 5:08 pm

Hi

Last comma makes an blank line to array, and than aIdx(i,1) is empty for dbusearea where i=2 -works correct for i=1 but len(aIdx)=2 and then crash!

::aIdx := { ;
{ "CUSTOMER" , { { "Upper(First)" , "First" , "Customer" } ,;
{ "Upper(Last)" , "Last" , "Customer" } ,;
{ "State" , "State" , "Customer" } } } ,;
}
Regards

Ing. Anton Lerchster
User avatar
alerchster
 
Posts: 94
Joined: Mon Oct 22, 2012 4:43 pm

Re: problem with dbUseArea

Postby Silvio.Falconi » Mon Apr 17, 2023 8:43 am

alerchster wrote:Hi

Last comma makes an blank line to array, and than aIdx(i,1) is empty for dbusearea where i=2 -works correct for i=1 but len(aIdx)=2 and then crash!

::aIdx := { ;
{ "CUSTOMER" , { { "Upper(First)" , "First" , "Customer" } ,;
{ "Upper(Last)" , "Last" , "Customer" } ,;
{ "State" , "State" , "Customer" } } } ,;
}

I really didn't understand why I use that code elsewhere and for a long time so I hadn't changed it, I couldn't understand why it didn't work
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: 7066
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

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