Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning the field name associated with tag
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00613089
Message ID:
00613172
Vues:
15
>Unfortunately, this code could produce incorrect results because of partial matches. For example, the field named 'ppe' would match UPPER.
>

Right. Here is a piece of code from our Search form:
		nTagNum=ASCAN(atags,theTag)
		cTagExpr=KEY(nTagNum)  && Get the Key
		* NSL 07/02/01
		* Found bug that included incorrect tags when there was a field that was a substr of another field
		* Ex strnum  and ownerstnum - user wanted ownerstnum, and prog displayed strnum in addition.
		*cTagExpr=CHRTRAN(cTagExpr,'+-() ',replicate(' ',5))  && AP proposed 07/02/01  - prev this line not there
		* NSL 07/02/01 Changed to only convert the plus. Negatives not usually in an index and the parens cause other problems
		cTagExpr=CHRTRAN(cTagExpr,'+(), ',replicate(' ',5))  && NSL 07/02/01  - added comma for functions in certain keys
		*--------------------------------------------------------------------------
		* -- Get all the fields that match with a CDX index tag
		*--------------------------------------------------------------------------
		DIMENSION laFieldInTag[1,2]
		lnZ=0
		FOR lnX=1 TO ALEN(laFieldNames,1)
			*IF laFieldNames[lnX]$cTagExpr  && Is this field name contained in the tag expression?
			IF ' '+laFieldNames[lnX]+' '$cTagExpr  && Is this field name contained in the tag expression? && AP proposed 07/02/01
				* If it is contained, then list it.  * replaces prev commented out line.
				lnZ=lnZ+1
				DIMENSION laFieldInTag[lnZ,2]
				laFieldInTag[lnZ,1]=laFieldNames[lnX]	
				laFieldInTag[lnZ,2]=AT(laFieldNames[lnX],cTagExpr)  && Save the start position
			ENDIF
		ENDFOR
BTW, I see a bug in this code. This line IF ' '+laFieldNames[lnX]+' '$cTagExpr
should be changed to
IF ' '+laFieldNames[lnX]+' '$" "+cTagExpr+" "
>>No, but you can use fcount() and field() in a FOR loop to figure out what fieldnames are in the KEY().
>>lparameter tcExpression
>>local lcFields
>>for lnI = 1 to fcount()
>>    if at(field(lnI), upper(tcExpression))
>>       if not empty(lcFields)
>>          lcFields = lcFields + ','
>>       endif
>>       lcFields = lcFields + field(lnI)
>>    endif
>>endfor
>>return lcFields
>>
>>>How can I get the field name associated with an index tag.
>>>
>>>For example: the KEY() function returns the index expression, but is there a function to return the field name that the tag belongs to?
>>>
>>>If I: INDEX ON UPPER(myfield) TAG mytag, ?KEY('mytable', 1) returns UPPER(myfield). I only want the field myfield returned.
>>>
>>>Thanks,
>>>
>>>Jerryt
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform