Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Case insensitive strtran()
Message
De
27/04/2001 14:50:44
 
 
À
27/04/2001 14:42:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00499747
Message ID:
00500973
Vues:
33
OOPS! This is what I was referring to!
>*	FUNCTION SUBSTRCI
>*		A case-insensitive SUBSTR(). In other words, characters in either the
>*		searched string or the string searched for are matched regardless of case, and
>*		the replacement string inserted.

>*	Parameters are in the same format as SUBSTR:
>*						TYPE		REQ/OPT
>*		tcSearched		C			REQ
>*		tcSearchfor		C			REQ
>*		tcReplace		C			OPT
>
>*	Although some parameters are identified as required,
>*	the routine recovers gracefully if they are of a different data type.
>*	The developer may want to add notification in these cases
>
>*	The function returns the value of the string as converted by the function.
>
>FUNCTION   SUBSTRCI
>PARAMETERS			tcSearched, tcSearchfor, tcReplace
>LOCAL				llContinue, lcReturn, lcReplace, lnSearchForSize, ;
>					lnOccuranceInReplace, lnOccurance
>
>lcReturn = IIF (VARTYPE (tcSearched) = "C", tcSearched, "")
>IF NOT EMPTY (tcSearchFor) AND VARTYPE (tcSearchFor) = "C"
>	llContinue = .T.
>	lcReplace = IIF (VARTYPE (tcReplace) = "C", tcReplace, "")
>	lnSearchForSize = LEN (tcSearchFor)
<B>
>	*&
>	*& The number of times the searched for text occurs in the Replacement text!
>	lnOccuranceInReplace = OCCURS(tcSearchfor,tcReplace)-1
>	lnOccurance = 0
>	*&	
</B>
>	DO WHILE llContinue
<B>
>		*&
>		*& Increment the occurance on each loop!
>		lnOccurance = lnOccurance + 1
>		*&
>		lnStart = ATC (tcSearchfor, lcReturn,lnOccurance)
</B>
>		llContinue = (lnStart > 0)
>		IF llContinue
>			lcReturn = LEFT (lcReturn, lnStart-1) + lcReplace + SUBSTR (lcReturn, lnStart + lnSearchForSize)
>		ENDIF
<B>
>		*&
>		*& Add any addition occurrences of the searched for text to the next occurance!
>		lnOccurance = lnOccurance + lnOccuranceInReplace
>		*&
</B>
>	ENDDO
>ENDIF
>RETURN lcReturn
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform