Page 1 of 1

Problem to Filter a dbf error on day week

Posted: Tue Jun 07, 2022 9:30 am
by Silvio.Falconi
I have to create a virtual archive in an array from a dbf taking into account some parameters
from year to year
what months of the year
which days of the week
what numbers of days of the month


But I have this error

Code: Select all | Expand

Error occurred at: 07-06-2022, 11:24:44
   Error description: Error BASE/1132  Limiti superati: accesso all'array
   Args:
     [   1] = A   {.T.,.T.,.T.,.T.,.T.,.T.} length: 6
     [   2] = N   0

Stack Calls
===========
   Called from:  => (b)EVAL( 443 )
   Called from:  => DBEVAL( 0 )
   Called from: .\source\function\DBFFUNC1.PRG => FW_DBFTOARRAY( 143 )
   Called from: .\source\classes\DATABASE.PRG => TDATABASE:HB_EXECFROMARRAY( 0 )
   Called from: .\source\classes\DATABASE.PRG => TDATABASE:DBFTOARRAY( 1622 )
   Called from: Source\test.prg => CREAZIONE_ARCHIVIO_VIRTUALE( 450 )



the error refers to the days that I load from an INI file



INI FILE

Code: Select all | Expand

[ARCHIVIO]
Mesi=111111111111
Giorni=111111
Day=1111111111111111111111111111111
Indici=111111111111110
Inizio=3914
Fine=10083
DataInizio=19460105
DataFine=20220517
 




local cGiorno := GetPvProfString(cSection, "Giorni","1111111", cIniFile)


For k=1 to 6 //len(aGiorni) LMMGVS
aadd(aCountGiorni,IIF(SubStr(cGiorno, k, 1)= "1",.t.,.f.))
next



Code: Select all | Expand


 oConteggio:=TDatabase():Open( , cDir+"Lotto", "DBFCDX", .T. )
    oConteggio:setorder(1)


    IF nLastRecords > 0
       nInit:=oConteggio:lastrec()-nLastRecords
       nEnd:= oConteggio:lastrec()
    ENDIF
         
     oConteggio:Exec( <||
     SET FILTER TO   (  dFirst <= FIELD->DATA .AND.             ;
                        dLast >=  FIELD->DATA .AND.             ;
                        aCountMesi[ MONTH( FIELD->DATA ) ]  .AND. ;
                        aCountGiorni[ DOW( FIELD->DATA )-1 ] .AND. ;   // make error here
                        aCountDate[ DAY( FIELD->DATA ) ]   )

      return nil
      > )

      oConteggio:gotop()
      xbrowser oConteggio
      aTempDbf := oConteggio:DbfToArray()

Re: Problem to Filter a dbf error on day week

Posted: Tue Jun 07, 2022 9:42 am
by Silvio.Falconi
I modify the number of day week add also Sunday

Image

Now the day are Seven


File Ini

Code: Select all | Expand

[ARCHIVIO]
Mesi=111111111111
Giorni=0111111
Day=1111111111111111111111111111111
Indici=111111111111110
Inizio=3914
Fine=10083
DataInizio=19460105
DataFine=20220517



For k=1 to 7//len(aGiorni) DLMMGVS
aadd(aCountGiorni,IIF(SubStr(cGiorno, k, 1)= "1",.t.,.f.))
next

But I have the same error

Re: Problem to Filter a dbf error on day week

Posted: Tue Jun 07, 2022 11:13 am
by nageswaragunupudi
This is wrong:

Code: Select all | Expand


aCountGiorni[ DOW( FIELD->DATA )-1 ]
 


If FIELD->DATA is Sunday, DOW( FIELD-> DATE ) evaluates to 1 and [ DOW[FIELD->DATA] - 1 ] evaluates to 0/
Naturally aCountGiorni[ 0 ] results in a runtime error.
This must be simple to understand.