Normal Topic Capital Letters - again (Read 709 times)
wildwood
Full Member
***
Offline


No personal text

Posts: 156
Location: New York
Joined: Apr 2nd, 2004
Capital Letters - again
Oct 21st, 2009 at 3:52am
Print Post Print Post  
I have a name field set up so that the first letter is capitalized, and the preceding letter is lower case. However when a name such as:
McDougal or McDaniel comes into my application it will be written as: Mcdougal and Mcdaniel. So I end up seperating the letters to appear as: Mc Dougal and Mc Daniel. This of course can foul things up in searches and simple field entry. Is there another setting to allow the first letter to be capitalized and then the next lower cased(?) with the third letter allowed to be capitalized in succession?

Thanks,
Peter
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Capital Letters - again
Reply #1 - Oct 21st, 2009 at 12:47pm
Print Post Print Post  
Here's your solution, or as least this is how I fixed the same issue.  Wink

Place this in the Global Code programming event:
Code
Select All
//=====================================================================================
// Interactive Initial Caps - Basic code from Ray Yoxall, interactive by Carl Underwood

SUBROUTINE cuInitialCaps()

Var vStr as String
Var vFirst as Char
Var vSnipet as String
Var vCnt as Int
Var vPos as Int

vCnt = 0
vStr = ThisElement
If @Len(vStr) > 0
{
	vPos = @CursorPosition(ThisElement)

	// vStr = ToLower(vStr)
	// Removal of the previous line allows you to force caps in the middle of a word or name.
	// Examples: MacDonald, McBride, StOnge, PO Box, etc.
	// Put it back in if you want to only allow the 1st letters to be in caps.
	vFirst = @Left(vStr, 1)
	vStr = @ReplFir(vStr, vFirst, ToUpper(vFirst))
	While vCnt < @Len(vStr)
	{
		If @Mid(vStr, vCnt, 1) = " "
		{
			vSnipet = vSnipet + @Left(vStr, vCnt)
			vStr = @Del(vStr, 0, vCnt)
			vCnt = 0
			vFirst = @Left(vStr, 1)
			vStr = @ReplFir(vStr, vFirst, ToUpper(vFirst))
		}
		vCnt = vCnt + 1
	}
	vSnipet = vSnipet + vStr
	ThisElement = vSnipet

	CursorPosition(ThisElement, vPos)
}

END SUBROUTINE
//=====================================================================================
 



Then place this in the "On Element Immediate Change" event for the element (field) that you want to use it in:
Code
Select All
cuInitialCaps() 



Here's how it works. As you type, the first character will automatically be in upper case, but you must manually press the shift key when entering the "D" in McDougal or McDaniel, etc.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Capital Letters - again
Reply #2 - Oct 21st, 2009 at 12:51pm
Print Post Print Post  
BTW, the reason I put it in a subroutine, is so you can easily use this in many fields. Simply put "cuInitialCaps()" in all the element events that could benefit from this feature. I use it in Name, Address, and City elements.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
wildwood
Full Member
***
Offline


No personal text

Posts: 156
Location: New York
Joined: Apr 2nd, 2004
Re: Capital Letters - again
Reply #3 - Oct 21st, 2009 at 9:39pm
Print Post Print Post  
Carl -  worked like a charm!! The best part was your explanation of where to place these codes was very clear to an old[size=20][/size] Q&A and Sesame "novice"

Thank you much,
Peter
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Capital Letters - again
Reply #4 - Oct 21st, 2009 at 10:17pm
Print Post Print Post  
You're welcome.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged