>>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 >>>>