Page 1 of 1

DbUseArea() Internal error 1010 after index with error

PostPosted: Thu Jul 27, 2006 2:36 pm
by dutch
Dear All,

I've found this error following message while build index files.

TEST.EXE caused a General Protection Fault in
module TEST.EXE at 0022:4221.

Choose close TEST.EXE will close.

After I close this error message box. The index file of last file is 0 byte and when I browse this database file the another error is below

DbUseArea() Internal error 1010

I try to find out and got some post that inform to increase stack size and set clipper //E:0 for disable EMS but it doesn't work. The error is still. How can I fix it?

Regards,
Dutch

PostPosted: Thu Jul 27, 2006 2:49 pm
by Detlef Hoefner
Hi Dutch,

could you please show us the piece of prg for your index creation?

Regards,
Detlef

Index corrupt after add TSbrowse

PostPosted: Thu Jul 27, 2006 3:36 pm
by dutch
Dear Detlef,

This is my index file procedure. I found this error has occur after I add TSbrowse.lib in my program. When I do not include Tsbrowse.ch and do not call TSbrowse the index run fine. I don't know why does it append?

Regards,
Dutch

*--------------*
Procedure IndexCheck(IndexAll)
OPENFILE('CCRIND','DX')
DX->(DbGotop())
do while !DX->(eof())
if ((!file(rtrim(DX->IND_DBF)+'.CDX').or.IndexAll) .and. !empty(DX->IND_NTX) .and. file(MEMVAR->cFoPath+rtrim(DX->IND_DBF)+'.DBF'))
cDbf := upper(rtrim(DX->IND_DBF))
OPENFILE(cDBF,,,.F.)
do while upper(rtrim(DX->IND_DBF)) == cDBF
cNtx := rtrim(DX->IND_NTX)
cExp := rtrim(DX->IND_EXP)
lAsend := iif(DX->IND_SORT='D',.F.,.T.)

if IndexAll .and. dow(date()) = 1
pack
end

MsgMeter( { | oMeter, oText, oDlg, lEnd | ;
BuildIndex( oMeter, oText, oDlg, @lEnd, cNtx, cExp, lAsend ) },;
"Indexing TAG "+cNtx,'Building index file, Please wait..' )

DX->(dbskip())
if !(upper(rtrim(DX->IND_DBF)) == cDBF)
DX->(dbskip(-1))
exit
end
end
CLOSEFILE(cDbf)
SELECT('DX')
end
DX->(dbskip())
end
CLOSEFILE('DX')
select(old_sel)
return

*----------------------------------------------*
Static Function BuildIndex( oMeter, oText, oDlg, lEnd, cNtx, cExp, lAsend )
oMeter:nTotal := Int(LastRec()/10)
if lAsend
INDEX ON &cExp TAG &cNtx ;
EVAL ( oMeter:Set( int(RecNo()/10) ), SysRefresh(), !lEnd ) ;
EVERY Int(Lastrec()/10)
else
INDEX ON &cExp TAG &cNtx ;
EVAL ( oMeter:Set( int(RecNo()/10) ), SysRefresh(), !lEnd ) ;
EVERY Int(Lastrec()/10) ;
DESCENDING
end
return nil

PostPosted: Thu Jul 27, 2006 3:44 pm
by Gale FORd
You do not want to index using trim(). The index has to remain a fixed length.

no trim in index expression

PostPosted: Thu Jul 27, 2006 3:58 pm
by dutch
Dear Gale,

The index expression has no trim() function.

Thanks,
Dutch

Strange behavier of index bar

PostPosted: Thu Jul 27, 2006 6:47 pm
by dutch
Dear All,

I try to create index without MsgMeter() and the error is not occur and still link TSbrowse. I think the problem is TSbrowse+MsgMeter().

- TSbrowse + MsgMeter() is problem
- MsgMeter() is no problem
- TSbrowse is no problem

Does anyone face the problem?

Regards,
Dutch

PostPosted: Thu Jul 27, 2006 10:08 pm
by Detlef Hoefner
Hi Dutch,

i doubt that either TsBrowse or MsgMeter is the cause of your protection fault.

I made some modifications to your code.
Because i didn't have the necessary dbf files and the rest of your code i couldn't try my suggest.
The most important IMO is to avoid calling lastrec() in the index command and the call of Sysrefresh() in the ordCondSet() call.

Perhaps this might help you?

Best regards,
Detlef

Code: Select all  Expand view
// ----------------------------
PROCEDURE IndexCheck( IndexAll )
// ----------------------------
   
   OPENFILE( 'CCRIND','DX' )
   
   DX->( DbGotop() )
   
   do while !DX->( eof() )
      if ( ( !file( rtrim( DX->IND_DBF ) + '.CDX' ) .or. IndexAll ) .and.;
             !empty( DX->IND_NTX ) .and. file( MEMVAR->cFoPath + rtrim( DX->IND_DBF ) + '.DBF' ) )

         cDbf := upper( rtrim( DX->IND_DBF ) )
         dbUseArea( .t., "comix", cDbf, "wrk", .f., .f.)

         if neterr()
            alert( "File " + cDbf + " could not be opened in exclusive mode.", {} )

            RETURN
         endif
                 
         do while upper( rtrim( DX->IND_DBF ) ) == cDBF
            cNtx   := rtrim( DX->IND_NTX )
            cExp   := rtrim( DX->IND_EXP )

            lAsend := if( DX->IND_SORT = 'D', .F., .T. )

            if IndexAll .and. dow( date() ) = 1
               wrk->( __dbPack() )
            endif

            MsgMeter( { | oMeter, oText, oDlg, lEnd | BuildIndex( oMeter, oText, oDlg, @lEnd, cNtx, cExp, lAsend ) },;
                          "Indexing TAG " + cNtx, 'Building index file, Please wait..' )

            DX->( dbskip() )
           
            if !( upper( rtrim( DX->IND_DBF ) ) == cDBF )
               DX->( dbskip( -1 ) )
               
               EXIT
            end
         end
         
         wrk->( dbCloseArea() )
         
         dbSelectArea( 'DX' )
      end
     
      DX->( dbskip() )
   end
   
   CLOSEFILE( 'DX' )
   select( old_sel )
return

// -------------------------------------------------------------------------
STATIC PROCEDURE BuildIndex( oMeter, oText, oDlg, lEnd, cNtx, cExp, lAsend )
// -------------------------------------------------------------------------
LOCAL nEvery := int( wrk->( lastrec() ) / 10 )


   oMeter:nTotal :=  wrk->( lastrec() )
   
   ordCondSet( nil, nil, nil, !lEnd, { || oMeter:Set( int( wrk->( recno() / 10 ) ) ), SysRefresh() }, nEvery, nil, nil, nil, nil, !lAsend, nil, .f., .f., .f., .f. )
   ordCreate( NIL,  cNtx, cExp, &( "{||" + cExp + "}" ), .f. )

RETURN

I will try

PostPosted: Fri Jul 28, 2006 2:30 am
by dutch
Dear Detlef,

Thank you for your suggestion and I will try.

Regards,
Dutch