Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
INDEX TAGS
Message
From
15/05/2001 21:08:27
David Fluker
NGIT - Centers For Disease Control
Decatur, Georgia, United States
 
 
To
15/05/2001 16:09:37
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00507484
Message ID:
00507651
Views:
13
>Is there a way to set an index to a table generically? In a class for a grid I capture the table name using THIS.RECORDSOURCE. I then want to set the order to a tagname that I've already created. This method works fine if I specifically index the table by using SET 'field name' tag 'field name' and send the tagname to the method. Now I'd like to make it as generic as possible by setting an index on whatever field I send to this class method. Somehow I can't get the correct syntax generically.

You can pass the tag name into the method as a parameter and then use SET ORDER TO TAG (OrderName). Put the variable holding the Tagname in parenthesis to make FoxPro resolve the variable. You might want to check to be sure the tag passed is a valid tag. If not, you could tell the user, or check to see if it's a valid field and INDEX on it.

Here is a sample.
Parameter cOrder

cTable = This.RecordSource
lValidTag = .F.
nCntr = 1

*: Check to be sure cOrder is a valid tag
cOrder = ALLTRIM(UPPER(cOrder))
DO WHILE (NOT EMPTY(TAG(nCntr))) AND lValidTag=.F.
	lValidTag = (cOrder == TAG(nCntr))
	nCntr = nCntr + 1
ENDDO

IF lValidTag
	SET ORDER TO TAG (cOrder) IN (cTable)
ELSE
	*: Do something
	MessageBox(cOrder + " is an invalid tag.")
ENDIF
David.
Previous
Reply
Map
View

Click here to load this message in the networking platform