=OpenTable(lcBldMstrDBF,'WorkFile') && Open Base BldMstr table select WorkFile *--- Create a table that holds the structure with validations that we want to create. ltBldMstr=addbs(gcTempPath)+'b'+sys(2015) copy structure extended to (ltBldMstr) use in WorkFile && Close bldmstr!bldmstr * -- PKP: JAN 2000: Since this Vallog is from the BldMstr Master * -- we don't need the relative name using here. =OpenTable(lcVallogDBF,'ValLog') && Open Base ValLog table select Vallog ltValLog=addbs(gcTempPath)+'v'+sys(2015) copy structure extended to (ltValLog) use in Vallog && Close bldmstr!vallog *--- Create the new database. if dbused(lcNewBldMstr) && Database is in use, close it first lcSetDB=set('database') set database to (lcNewBldMstr) close database if !empty(lcSetDB) set database to (lcSetDB) endif endif local lcOldError, lnError lcOldError=on('error') lnError=0 on error lnError=error() create database (lcNewBldMstr) on error &lcOldError && Retore previous Error Handler **** Error cases if lnError=3 && File is in Use =messagebox(lcNewBldMstr+' database could not be created!',48,'Warning') select (lnOldArea) if lcOldSafety='ON' set safety on endif oJC.CurAppStat='I' return .f. endif if lnError<>0 && Another problem occurs local lnRows lnRows=aerror[laErrors] =messagebox('Error # '+transform(laErrors[1])+ ; ' "'+laErrors[2]+'" occurs...',48,'Warning') select (lnOldArea) if lcOldSafety='ON' set safety on endif oJC.CurAppStat='I' return .f. endif *************************************** *--- Update the table_name field value in this extended structure so when added to dbc it has the correct name. *---- First open extended table in same work space. =OpenTable(ltBldMstr,'ltBldMstr') select ltBldMstr locate replace table_name with (lcNewBldMstrName+'_B') in ltBldMstr use in ltBldMstr && Close the table *--- Update the table_name field value in this extended structure so when added to dbc it has the correct name. *---- First open extended table in same work space. =OpenTable(ltValLog,'ltValLog') select ltValLog locate replace table_name with (lcNewBldMstrName+'_V') in ltValLog use in ltValLog && Close the table *--- Create the new table based and add to the dbc. wait window nowait "Wait while creating "+lcNewBldMstr+'_B'+".DBF ..." && NSL 4/5/2000 added message select 0 create (lcNewBldMstr+'_B') database (lcNewBldMstrName) from (ltBldMstr) flush && To save modifications on the disk wait window nowait "Wait while creating "+lcNewBldMstr+'_V'+".DBF ..." && NSL 4/5/2000 added message select 0 create (lcNewBldMstr+'_V') database (lcNewBldMstrName) from (ltValLog) && This table would be opened exclusively *--- Create necessary index(s). =GenerateIndexes('VALLOG',lcNewBldMstrName+'_V') flush