Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trimming blanks on a memo field
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00625134
Message ID:
00625312
Vues:
10
Hello Steve/Eric,

>I know you can you use ALLTRIM() & TRIM() on character expressions to trim blanks off, but it does not work for a memo field. How do you go about trimming blanks off of a memo field? Thanks!
>
>Steve Kuhn

I'm assuming you want to remove all leading and trailing characters from the memo field. The following function removes all leading/trailing space,CR,LF and tab characters from a string. You can modify lcCharsToTrim if you want to trim different characters.

If you have a memo field called 'notes', you can issue:
replace notes with allTrimMemo(notes)
HTH...
function allTrimMemo
lparameters lcInString
	local 	lcCharsToTrim, ;    && string containing all characters to be trimmed
			lcOutString, ;
			lnLength, ;
			lnTrim
			
	* trim leading & trailing CR,LF,spaces, and tabs
	lcCharsToTrim = chr(13) + chr(10) + ' ' + chr(9)
	
	lcOutString = allTrim(lcInString)
	
	* trim trailing items
	lnLength = len(lcOutString)
	lnTrim = 0
	do while substr(lcOutString,lnLength - lnTrim, 1) $ lcCharsToTrim
		lnTrim = lnTrim + 1
	enddo
	if lnTrim > 0
		lcOutString = substr(lcOutString,1,lnLength - lnTrim)
	endif
	
	* trim leading items
	lnTrim = 0	
	do while substr(lcOutString, lnTrim + 1, 1)	$ lcCharsToTrim
		lnTrim = lnTrim + 1
	enddo
	if lnTrim > 0
		lcOutString = substr(lcOutString,lnTrim+1,lnLength - lnTrim)
	endif
	
	return lcOutString
endproc
Steve Gibson
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform