Roger,
Not using ADS, if a user attempts to open a file and it is locked or damaged it at time just sits there. Does not get a file in use. Always has an index involved so it is most likely a bad index and Xbase apparently does not know what to do with it. We have the option to open or give the user an error, and if the file index does not match normally an error will occur. In some cases the user just locks up until he closed our app completely. No error or fatal error.
Had a user today that closed the file on the network using computer management, and then it was fine. Most of our users do not have access to do that.
do you know of any method to check for this and exit or give an error? Difficult to show you an example because it is so rare.
For one use we have a routine that checks all files with indexes if they have a slowdown to see if any file stops and will not open, or has a long delay.
300+ files normally takes about 3 seconds to check the files when they have a slowdown on their network. Today it locked up on one of them, but they had no way to get out of the menu because it just sat there...
Here is the open file function we use just for that routine: Nothing is exclusive.
Opened with ==> IF !fix_OpenDBF( newname, .f.)
FUNCTION fix_OpenDBF( cDBF, lExclusive, lNew, cRDD, cAlias, lReadOnly )
***************************************************************************
*** This function assumes that the default RDD is used to open files
*** and that the alias is the default value of the DBF file name without
*** an extension
***------------------------------------------------------------------------
*** This function defaults to NEW and SHARED when not specified
*** (example: ois_OpenDBF( cDBF ) would open cDBF as SHARED in a NEW area
***************************************************************************
LOCAL n, nPos, nArea
LOCAL nRetries := 0
LOCAL bSaveErrorBlock, oError
LOCAL lShared
cDBF := ALLTRIM( cDBF )+".dbf"
*** assign defaults if parameters not specified
***------------------------------------------------------------------------
lExclusive := IF( lExclusive == Nil, .F., lExclusive ) // default: shared
lShared := !lExclusive
lNew := IF( lNew == Nil, .F., lNew ) // default: current work area
lReadOnly := IF( lReadOnly == Nil, .F., lReadOnly ) // default: not readonly
cRDD := IF( cRDD == Nil, "FOXCDX", cRDD ) // default: FOXCDX
IF cAlias == Nil // if parameter not defined, derive from file name
cAlias := cDBF
*** Remove any specified file extension
***------------------------------------------------------
nPos := RAT( '.', cDBF )
cAlias := IF( nPos > 0, SUBS( cDBF, 1, nPos-1 ), cAlias )
*** Remove any specified path
***------------------------------------------------------
nPos := RAT( "\", cAlias )
cAlias := IF( nPos > 0, SUBS( cAlias, nPos+1), cAlias ) // default: DBF file name, no extension
ELSE
*** use the value passed as parameter
ENDIF
*** Define error block
***------------------------------------------------------------------------
bSaveErrorBlock := ErrorBlock( {|e| Break(e)} )
DO WHILE .T.
BEGIN SEQUENCE
DBUSEAREA( lNew, "FOXCDX", cDBF, cAlias, lShared, lReadOnly )
RECOVER USING oError
//IF nRetries++ < 20 // try 20 times before reporting error
// LOOP
//ENDIF
n := 1 // default user option to 'RETRY'
IF ( nArea := SELECT( cAlias ) ) <> 0 // cDBF opened successfully
***-------------------------------------------------------------------
*** this section was added when using the USE command instead of the
*** DBUSEAREA() function; with the USE command, the NetErr() function
*** was returning .T. every time and the oError:genCode value was
*** indicating that the file was not open even when it was; the
*** DBUSEAREA() function does not appear to have the same problem
***-------------------------------------------------------------------
DBSELECTAREA( cAlias )
ErrorBlock(bSaveErrorBlock) // Restore old error code block
RETURN( .T. )
ELSEIF oError:genCode <> 0 // display warning
if skipmsg .and. alltrim(Upper(cdbf))='CDXLIST'
quit
endif
///if file is stopen!!!use this message///
IF DSTART .or. skipmsg ///DELAYED START.NO MESSAGE. CONTINUE WITH NEXT FILE.
RETURN .T.
ENDIF
n := DC_GuiAlert(,"Unable to continue. ;" + ;
"The index file is damaged or opened by another user;" + ;
"File Name: "+cdbf +" ; "+ ;
" " ,{ "Continue", "Quit" } ,14,"Error Warning",,,{"9.Arial Bold","9.Arial Bold" })
if n=1
return .t.
else
return .f.
endif
endif
ENDSEQUENCE
EXIT // exit DO WHILE if successful
ENDDO
ErrorBlock(bSaveErrorBlock) // Restore old error code block
RETURN( .T. ) // return and report success
Open file Error
Re: Open file Error
I think you need to be sure if the lockup is really at the OS level or Xbase++ level.
If it is something in Xbase++, then you should be able to terminate with Alt-C, provided that you have SetCancel(.t.)
An Alt-C termination will create XPPFATAL.LOG.
In the log you will know which line of code caused the lockup.
If it's dbUseArea() or OrdListAdd(), that says that those functions are locked up.
It may be something in a loop in your code that's causing the lockup.
If it is something in Xbase++, then you should be able to terminate with Alt-C, provided that you have SetCancel(.t.)
An Alt-C termination will create XPPFATAL.LOG.
In the log you will know which line of code caused the lockup.
If it's dbUseArea() or OrdListAdd(), that says that those functions are locked up.
It may be something in a loop in your code that's causing the lockup.
The eXpress train is coming - and it has more cars.
Re: Open file Error
hi,
enhance your FUNCTION fix_OpenDBF() with DC_DbeType( cDbf )
it seem me that you still have "mixed" Fox DBF Typeomni wrote:Always has an index involved so it is most likely a bad index and Xbase apparently does not know what to do with it.
enhance your FUNCTION fix_OpenDBF() with DC_DbeType( cDbf )
Code: Select all
? DbeInfo( COMPONENT_DATA, DBE_NAME ),;
DbeInfo( COMPONENT_ORDER, DBE_NAME ),;
DbeInfo( COMPONENT_DATA, FOXDBE_CREATE_2X),;
DbeInfo( COMPONENT_DATA, FOXDBE_LOCKMODE ),;
DbeInfo( COMPONENT_DATA,DBE_VERSION),;
VAR2CHAR( DC_DbeType( cDBF ) )
FOXDBE CDXDBE J 1002 1.90.355 {245, "Foxpro 2.x/Ads with memo", "FOXCDX/ADSDBE", "CDX"}
FOXDBE CDXDBE J 1004 1.90.355 {245, "Foxpro 2.x/Ads with memo", "FOXCDX/ADSDBE", "CDX"}
FOXDBE CDXDBE N 1003 1.90.355 {48, "Visual Foxpro/Ads", "FOXCDX/ADSDBE", "CDX"}
greetings by OHR
Jimmy
Jimmy