Page 1 of 1

To Nages: Record deleted but make error also RESOLVED

PostPosted: Wed Nov 22, 2023 9:34 am
by Silvio.Falconi
Now the record is deleted on archive but when save the array on dbf make error

the error
Code: Select all  Expand view

Error description: Error BASE/1102  Argument error: UPPER
   Args:
     [   1] = A   {"00003",4.10,11.00,17.60,0.90,.T.,0,16777215,.F.,"molto fine  ","1234567890123                ... } length: 32

Stack Calls
===========
   Called from:  => UPPER( 0 )
   Called from: .\source\function\DBFFUNC2.PRG => (b)FW_SAVEARRAYTODBF( 879 )
   Called from:  => ASCAN( 0 )
   Called from: .\source\function\DBFFUNC2.PRG => FW_SAVEARRAYTODBF( 879 )
   Called from: .\source\classes\DATABASE.PRG => TRIGHEMODULI:HB_EXECFROMARRAY( 0 )
   Called from: .\source\classes\DATABASE.PRG => TRIGHEMODULI:FW_SAVEARRAYTODBF( 1624 )
   Called from: TEST.PRG => TESTDEL( 131 )
   Called from: TEST.PRG => MAIN( 26 )



TO save a xbrowse ( with array with 31 record + "recno()") I made


Check if there are deleted records

Code: Select all  Expand view
     if ! Empty( oBrowse:aDeleted )
             AEval( oBrowse:aDeleted, { |a| a[ 32 ] := -a[ 32 ] } )
            oDbfMod:SaveArrayToDBF( cItemFlds, oBrowse:aDeleted )
         endif


save on first record the code (oRec:codRep) and save on 29 record the counter "00001"

Code: Select all  Expand view
AEval( aDataForm, { |a| a[ 1 ] := oRec:codRep } )
         AEval( aDataForm, { |a,i| a[ 29 ] := strzero(i,5) } )


save on archive ( here make the error )

Code: Select all  Expand view
oDbfMod:FW_SaveArrayToDBF( aDataForm,cItemFlds,,.t. )

Re: To Nages: Record deleted but make error also

PostPosted: Wed Nov 22, 2023 10:05 am
by Silvio.Falconi
this morning I corrected with
Code: Select all  Expand view
if ! Empty( oBrowse:aDeleted )
              AEval( oBrowse:aDeleted, { |a| a[ 32 ] := -a[ 32 ] } )
              oDbfMod:SaveArrayToDBF( cItemFlds, oBrowse:aDeleted )
           endif
           //save
         AEval( aDataForm, { |a| a[ 1 ] := oRec:codRep } )
         AEval( aDataForm, { |a,i| a[ 29 ] := strzero(i,5) } )
         oDbfMod:ArrayToDBF( aDataForm ,  cItemFlds,, .t., .t. )


on test seem run ok

when I put into prg make error

Error description: Error BASE/1070 Argument error: ==
Args:
[ 1] = C
[ 2] = N 0

Stack Calls
===========
Called from: .\source\function\DBFFUNC2.PRG => FW_FIELDSPUT( 986 )

Re: To Nages: Record deleted but make error also

PostPosted: Wed Nov 22, 2023 2:45 pm
by nageswaragunupudi
There is no problem with oBrw:aDeleted array.

When a programmer tries to save this array or any other array to DBF it is his responsibility to match the type of the array elements with the datatypes of the corresponding fields of the DBF.

Re: To Nages: Record deleted but make error also

PostPosted: Wed Nov 22, 2023 6:15 pm
by Silvio.Falconi
nageswaragunupudi wrote:There is no problem with oBrw:aDeleted array.

When a programmer tries to save this array or any other array to DBF it is his responsibility to match the type of the array elements with the datatypes of the corresponding fields of the DBF.


I actually don't know why when I delete one it assigns a number in position 32, where I added the "recno" field as it is done on yunus.prg
If I add and delete, a number is not inserted
So we arrived at this conclusion which seems to work

AEval( oBrowse:aDeleted, { |a| IF(a[ 32 ] ==0, a[32] := len(oBrowse:aDeleted),nil) } )

also because the programmer checked for days the exact correspondence between fields and values in the fields and everything seemed fine except for the last field which in reality is not a field from the archive but has been added into the array