Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ensure string has no special characters
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01292266
Message ID:
01292413
Views:
31
This message has been marked as the solution to the initial question of the thread.
>I'm doing a bad job of explaining it. It's not the cursor's name (alias), it's the field names within the cursor that gets created.

Perhaps these functions can be of help. The first one will construct a valid field name by replacing invalid characters. The second will check a 'field names' array for duplicate values.
*	Guarantees that a fieldname is valid for VFP.
FUNCTION GuaranteeFieldName( tcFName )
	*
	local lcC, lcC1, lm
	*
	lcC = alltrim( tcFName )
	*
	if not isalpha( lcC )
		*
		lcC = 'X' + lcC
	endif
	*
	for lm = 2 to len( alltrim( lcC ) )	&& replace troublesome characters with an underscore
		*
		lcC1 = substr( lcC, lm, 1 )
		*
		if not lcC1 = '_' and not isalpha( lcC1 ) and not isdigit( lcC1 )
			*
			lcC = left( lcC, lm - 1 ) + '_' + substr( lcC, lm + 1 )
		endif
	next
	*
	RETURN lcC

FUNCTION CheckFieldNames
	lparameter taField		&& one-dim

	local ln, lcMsg

	lcMsg = ""
	
	for ln = 1 to alen( taField )
		*
		if ascan( taField, taField[ ln ], ln + 1, -1,  1, 1+6 ) > 1	&& 1+6=case-insensitive + exact on
			*
			lcMsg = "Duplicate field name found: " + taField[ ln ]
			EXIT
		endif
	next
	
	RETURN lcMsg
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform