DbUseArea() Internal error 1010 after index with error

Post Reply
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

DbUseArea() Internal error 1010 after index with error

Post 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
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Post by Detlef Hoefner »

Hi Dutch,

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

Regards,
Detlef
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Index corrupt after add TSbrowse

Post 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
Gale FORd
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston
Contact:

Post by Gale FORd »

You do not want to index using trim(). The index has to remain a fixed length.
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

no trim in index expression

Post by dutch »

Dear Gale,

The index expression has no trim() function.

Thanks,
Dutch
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Strange behavier of index bar

Post 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
User avatar
Detlef Hoefner
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany
Contact:

Post 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

// ----------------------------
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 
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

I will try

Post by dutch »

Dear Detlef,

Thank you for your suggestion and I will try.

Regards,
Dutch
Post Reply