Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Indexer
Message
From
27/05/2003 12:18:50
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Indexer
Miscellaneous
Thread ID:
00793154
Message ID:
00793154
Views:
61
Hi ,

i use one class that i found in U.T. to reindexer tables . Works very good !

But now i have a problem . I have two versions of same program that i made .

The first version , have 12 tables . The second version have 28 tables in dbc .

This class make one table , IndexMetaData with information of all table in dbc .

When i make indexMetaData in my Pc , this table make reference to all tables in dbc on my computer . But , people that use my first version , don´t have some tables , that i have , and they don´t need have this tables .

when i run this , in pc of this people , open one dialog box to i select one table .
I only want , change this class , to don´t open this dialog box , ignore , and skip to next record ( table in dbc ).
Can you found , where i may change this code , to make this .
I think it´s easy for some of you .
Thanks
*!* This rebuilds the Indexes based on the IndexMetaData table.
LPARAMETER tlDeleteIndex
LOCAL lcOldSafety, lcCDXName, lcTableName, lcOldCollate, lcOldError, lcNoError

lcError = .F.

lcOldError = ON([Error])
ON ERROR lcError = .T.

*!* Close the databases
CLOSE DATABASE ALL

*!* Try and open it exclusivley
OPEN DATABASE (This.DBC_Name) EXCLUSIVE 

*!* If You couldn't open it return .F.
IF lcError
	RETURN .F.
ENDIF


*!* Check for the Matadata Table for rebuilding
IF !FILE([IndexMetaData.DBF])
	=MESSAGEBOX([Não consigo reindexar os ficheiros , por favor contacte a Elaconta], 16, [Erro ao Indexar])
	RETURN .F.
ENDIF

*!* Begin Rebuild process
lcOldSafety = SET([Safety])
SET SAFETY OFF

lcOldCollate = SET([Collate])

SELECT Table_Name DISTINCT FROM IndexMetaData WHERE !EMPTY(Table_Name) INTO CURSOR TableList

SELECT TableList	&& Table To Scan

*!* Check for CDX File and Delete them.
SCAN 
	SELECT 0
	USE (ALLT(TableList.Table_Name)) EXCL		&& Open the Table
	DELETE TAG ALL						&& Delete the Tags
	USE IN (ALLT(TableList.Table_Name))		&& Close the Tables
ENDSCAN

*!* Close the temp table.
USE IN TableList

*!* Reselect the index table and begin rebuilding the indexes
SELECT IndexMetaData
GO TOP IN IndexMetaData

lcTableName = []

SCAN
	*!* If the table name has changed then clise the old one and open the new one
	IF lcTableName # ALLT(IndexMetaData.Table_name)
		*!* make sure the table is open before closing it
		IF USED(lcTableName)
			USE IN (lcTableName)
		ENDIF
		*!* Open the new table
		USE (ALLT(IndexMetaData.Table_name)) IN 0 EXCLUSIVE
		WAIT WINDOW NOWAIT NOCLEAR [A reconstruir os indices para : ]+ALLT(IndexMetaData.Table_name)
	ENDIF

	*!* Store the last table used before going to the next on
	*!* to test to see if its open.
	lcTableName 	= ALLT(IndexMetaData.Table_name)
	
	*!* Store the Info to variables
	lcTagStructure 	= ALLT(IndexMetaData.Index_Tag)
	lcTagName		= ALLT(IndexMetaData.Index_Name)
	lcFilter 		= ALLT(IndexMetaData.Tag_Filter)
	lcCollate		= ALLT(IndexMetaData.Collate)
	llAscending 	= IIF(IndexMetaData.Ascending,"ASCENDING", "DESCENDING")
	lcType 			= ALLT(IndexMetaData.Index_Type)
	lcIndexType 	= []

	*!* Needed to build string 
	DO CASE 
		CASE lcType = [U]
			lcIndexType = [UNIQUE]
		CASE lcType = [C]
			lcIndexType = [CANDIDATE]
	ENDCASE
	
	*!* Select the table to index
	SELECT (lcTableName)
	
	*!* Set The Collate
	SET COLLATE TO lcCollate

	*!* Build the Index string
	IF [-] $ lcTagName
		=MESSAGEBOX([Invalid "Minus" Character In Tag Name.]+CHR(13)+ ;
					[Index Skipped You Will Need To Create It Manually], 64, [Reindexer Warning])
	ELSE
		*!* Note for Users with Large Tags...
		WAIT WINDOW NOWAIT NOCLEAR [Rebuilding Tag ]+lcTagName+[ For Table ]+lcTableName

		*!* Added the ability for a Filter in the Primary Key.
		IF lcType = [P]	&& Primary Keys are diffrent
			IF EMPTY(lcFilter)
				ALTER TABLE &lcTableName ADD PRIMARY KEY &lcTagStructure TAG &lcTagName
			ELSE
				ALTER TABLE &lcTableName ADD PRIMARY KEY &lcTagStructure FOR &lcFilter TAG &lcTagName
			ENDIF			
		ELSE
			*!* Build String for all other Indexes
			lcIndexCommand = [INDEX ON ]+lcTagStructure+[ TAG ]+lcTagName
			lcIndexCommand = lcIndexCommand + IIF(EMPTY(lcFilter), [], [ FOR ]+lcFilter)
			lcIndexCommand = lcIndexCommand + [ ] + llAscending
			lcIndexCommand = lcIndexCommand + [ ] + lcIndexType

			*!* Execute the String to build the index
			&lcIndexCommand
		ENDIF
	ENDIF
	
	SELECT IndexMetaData

ENDSCAN

*!* Close The Last Table opened
IF USED(lcTableName)
	USE IN (lcTableName)
ENDIF

This.ReBuild_Relations()

IF USED([IndexMetaData])
	USE IN IndexMetaData
ENDIF

SET COLLATE TO lcOldCollate
SET SAFETY &lcOldSafety
ON ERROR &lcOldError 

WAIT CLEAR

RETURN !lcError


Pedro Silva

world is wonderful with your help .

Next
Reply
Map
View

Click here to load this message in the networking platform