Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SDT and Error Handling
Message
De
12/05/2005 14:37:25
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Stonefield
Titre:
SDT and Error Handling
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01013546
Message ID:
01013546
Vues:
56
SDT 6.2a
We are redesigning our open table method to create a table if it does not exist. That is working correctly, however, the table is not opened because 'Retry' is not being captured in the dbcxmmgr error method.

We open a table as so:
IF !USEFILE('lbridges','dbSystem','BRIDGEKEY','','')
   *--Error message
The new usefile program:
PARAMETERS ufile, udbc, uorder, ualias, uparm1, uparm2, uparm3

PRIVATE xreturn, udir
xreturn = .F.
udir = ''

IF EMPTY(ufile)
	WAIT WINDOW 'Error in USEFILE.PRG - File name is missing.'
	RETURN xreturn
ENDIF
IF '.' $ ufile
	ufile = LEFT(ufile,AT('.',ufile)-1)
ENDIF

IF EMPTY(udbc)
	udbc = ''
ELSE

	*---If the udbc contains a '\' assume it is a directory name.  

	IF OCCURS('\', udbc) > 0
		udir = udbc
		IF RIGHT(udir,1) <> '\'
			udir = udir + '\'
		ENDIF
	ENDIF
	
ENDIF

IF EMPTY(ualias)
	ualias = ''
ENDIF

uexclu = .F.

IF !EMPTY(uparm1)
	DO setparms WITH uparm1
ENDIF
IF !EMPTY(uparm2)
	DO setparms WITH uparm2
ENDIF
IF !EMPTY(uparm3)
	DO setparms WITH uparm3
ENDIF

* Set up error handler
ON ERROR DO ErrorHandler WITH ERROR(), MESSAGE(), LINENO()

* Open the table
IF !EMPTY(udir)
	xreturn = oMeta.oSDTMgr.OpenTable(udir+ufile, uorder, uexclu, ualias)
ELSE
	IF !EMPTY(udbc)
		oMeta.SetDatabase(udbc)
	ENDIF
	xreturn = oMeta.oSDTMgr.OpenTable(ufile, uorder, uexclu, ualias)
ENDIF

ON ERROR DO errors WITH PROGRAM()

RETURN xreturn

*---------------------------------------------------------------------------
PROCEDURE setparms
PARAMETERS xparm

DO CASE
CASE TYPE('xparm') <> 'C'

CASE UPPER(xparm) = 'EXCLU'
	uexclu = .T.
ENDCASE

RETURN

*---------------------------------------------------------------------------
PROCEDURE ErrorHandler
PARAMETERS tnError, tcMessage, tnLineno

DO CASE

*File "<file>" does not exist.

CASE tnError = 1 AND NOT EMPTY(oMeta.oSDTMgr.cAlias)
	oMeta.oSDTMgr.Update(oMeta.oSDTMgr.cAlias)

	RETURN 'Retry'
	
* If an index error occurred (5 = record out of range, 19 = index doesn't match
* DBF, 20 = record not in index, 23 = index expression too big, 26 = table
* isn't ordered, 112 = invalid key length, 114 = index file doesn't match DBF,
* 1124 = key too big, 1683 = tag not found, 1707 = structural CDX not found,
* 1567 = primary key invalid), reindex the table.

CASE INLIST(tnError, 5, 19, 20, 23, 26, 112, 114, 1124, 1683, 1707, 1567) AND NOT EMPTY(oMeta.oSDTMgr.cAlias)
	oMeta.oSDTMgr.Reindex(oMeta.oSDTMgr.cAlias)

	RETURN 'Retry'

* If the table or memo is corrupted (15 = not a table, 41 = memo missing or
* invalid, 2091 = table has become corrupted), repair it.

CASE INLIST(tnError, 15, 41, 2091) AND NOT EMPTY(oMeta.oSDTMgr.cAlias)
	oMeta.oSDTMgr.Repair(oMeta.oSDTMgr.cAlias)

	RETURN 'Retry'
ENDCASE

RETURN ''
In the case when the table does not exist, the below runs (the table is created as it should be):
CASE tnError = 1 AND NOT EMPTY(oMeta.oSDTMgr.cAlias)
	oMeta.oSDTMgr.Update(oMeta.oSDTMgr.cAlias)

	RETURN 'Retry'
however, the error routine of dbcx mgr does not capture the 'Retry' sent back to it and so the table is never opened:
			if left(lcError, 3) = 'DO ' or '=' $ lcError   && <--this is true
				&lcError                               && <--this runs (retry not captured)
				lcReturn = ccMSG_CONTINUE && <--changed to continue, need it retry

			else
				lcReturn = &lcError
			endif left(lcError, 3) = 'DO ' ...
	endcase
Any ideas?

TIA!
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform