>* support user Escapes for interrupting the main loop >lcOldOnEsc = on('escape') && save previous Escape handler >lcOldSetEscape = set('escape') && previous Escape enablement state >set escape on && enable escape handling >on escape oValid.StopProcess("Are you sure you want to stop Modify Process?") && Allows for stopping of the process. >do while oValid.lContinue && Till termination > for lnI=1 to m.tnCount && loop for all selected databases > if not oValid.lContinue > exit > endif > if not file(forceext(taDBC[m.lnI],'DBC')) > =messagebox("Database "+taDBC[m.lnI]+" is not found!",48,"File does not exist") > loop > endif > llDBCExist=.t. > if GetDBC(alltrim(taDBC[m.lnI])) && Opens the database for possible changes && should be in the path > lcDBCPath=addbs(justpath(fullpath(alltrim(taDBC[m.lnI])))) > if !empty(m.lcWholeLogStr) && Separate Databases > lcWholeLogStr=m.lcWholeLogStr+CR+replicate("*",65)+CR > else > lcWholeLogStr=upper("Starting checking "+ m.tcAction+" at ")+ttoc(m.lnStartTime)+CR > endif > lcWholeLogStr= m.lcWholeLogStr+ttoc(datetime())+" Database: "+alltrim(taDBC[m.lnI]) > release laTables > lnTables=adbobjects(laTables, "TABLE") && Create list of all tables in Database > =asort(laTables) > for lnK=1 to m.lnTables > if not oValid.lContinue > exit > endif > lcTableName=upper(alltrim(laTables[m.lnK])) > lnMinSize=3*(GetFileSize(m.lcDBCPath+m.lcTableName+".DBF")+ ; > GetFileSize(m.lcDBCPath+m.lcTableName+".FPT") + ; > GetFileSize(m.lcDBCPath+m.lcTableName+".CDX")) > if vartype(m.pcTempDrive)"C" > pcTempDrive=justdrive(sys(2023)) > endif > if GetFreeSpace(m.pcTempDrive, m.llFirstTime) =messagebox("Could not check and possibly alter "+m.lcTableName+" because it's not enough free space!"+CR + ; > "Free space, then repeat the process!",48,"Not enough space") > llStop=.t. > exit > else > llTableOpened=.f. > if m.lcTableName"NEXTID" > if OpenTble(m.lcTableName,'WorkFile','exclusive') && Open Table excl with alias WorkFile > lcWholeLogStr= m.lcWholeLogStr+CR+"Table: "+ m.lcTableName+ ; > " starting checking "+m.tcAction+" at "+ttoc(datetime())+CR > llTableOpened=.t. > if m.tcAction='Structure' > =Modify_Structure(m.lcTableName, alltrim(taDBC[m.lnI]), @lcWholeLogStr) > endif && Structure changes only > lcWholeLogStr= m.lcWholeLogStr+CR+"Table: "+m.lcTableName+ ; > " starting checking indexes at "+ttoc(datetime())+CR > =Modify_Indexes(m.lcTableName, alltrim(taDBC[m.lnI]), @lcWholeLogStr) > use in select('WorkFile') > flush > else && Table was not opened > lcWholeLogStr= m.lcWholeLogStr+ ; > ttoc(datetime())+" Table "+ m.lcTableName+ ; > " was opened by another user and therefore was not checked..."+ ; > +CR+replicate("_",65)+CR > > endif > endif > llFirstTime=.f. > endif > endfor && End loop for all tables within Database > if oValid.lContinue > lcWholeLogStr= m.lcWholeLogStr+ ; > ttoc(datetime())+" Finished checking all tables in "+alltrim(taDBC[m.lni])+CR > endif > close database > lcDBCPath=addbs(justpath(fullpath(forceext(taDBC[lni],'DBC')))) > erase (m.lcDBCPath+'*.bak') > erase (m.lcDBCPath+'*.tbk') > endif > endfor && End loop for all selected databases > exit >enddo>