John Marrone
Proper case a string November 21, 2008 12:59PM |
DarrenF
Re: Proper case a string November 21, 2008 01:19PM |
John Marrone
Re: Proper case a string November 21, 2008 02:01PM |
PROCEDURE Proper(str is string) LOCAL i is int str = NoSpace(str) numChars is int = Length(str) chr, retStr is string lastSpc is boolean = True FOR i = 1 TO numChars chr = Middle(str,i,1) IF chr = " " THEN retStr += chr lastSpc = True ELSE IF lastSpc THEN retStr += Upper(chr) lastSpc = False ELSE retStr += Lower(chr) END END END RESULT retStr:-)
DerekT
Re: Proper case a string November 24, 2008 05:26PM |
PROCEDURE lpCase(pString is string) lbIsSpace is boolean = False lcToCheck is character lcCaseRes is string lnSpaceCnt is int = StringCount(pString," ",IgnoreCase) //Check for spaces in the source string lnStrLen is int = Length(pString) //Number of characters to check lsCaseSet is string IF lnSpaceCnt > 0 THEN FOR i = 1 TO lnStrLen //Loop through all characters lcToCheck = Middle(pString,i,1) //Set character to check SWITCH True CASE i = 1: lcCaseRes = StringFormat(lcToCheck,ccUpCase) //Set 1st character to upper case OTHER CASE IF NOT lbIsSpace THEN //Process lower case (including spaces)if lbIsSpace = False lcCaseRes = StringFormat(lcToCheck,ccLowCase) ELSE lcCaseRes = StringFormat(lcToCheck,ccUpCase) //Set to upper case if lbIsSpace = True lbIsSpace = False //then reset the "lbIsSpace" flag END IF lcToCheck = " " THEN //If the character just processed is a space lbIsSpace = True //then set the "lbIsSpace" flag to True for next iteration END END lsCaseSet += lcCaseRes //Concatinate the individual characters END pString = lsCaseSet //Update the received parameter with the new string for return END
Chris L
Re: Proper case a string (in entry fields) December 03, 2008 09:17AM |
John Marrone
Re: Proper case a string (in entry fields) December 03, 2008 10:49PM |
Art Bonds
Re: Proper case a string (in entry fields) December 04, 2008 12:39AM |
Jimbo
Re: Proper case a string (in entry fields) December 04, 2008 10:07AM |
Moderator |
Merijn
Re: Proper case a string December 04, 2008 10:31AM |
sTmp, sOutput, sInput is string="merijn van der wijk" iPiece is int iMax is int = StringCount(NoSpace(sInput)," ") + 1 FOR iPiece=1 TO iMax sTmp=StringFormat(Lower(ExtractString(sInput,iPiece," "))) // only upper large words and allways the first word IF Length(sTmp) > 3 OR iPiece=1 THEN sTmp[ [1] ] =Upper(sTmp[ [1] ]) sOutput+=sTmp + " " END sOutput=NoSpace(sOutput)
Jimbo
Re: Proper case a string December 04, 2008 10:38AM |
Moderator |
Merijn
Re: Proper case a string December 04, 2008 10:51AM |
Art Bonds
Re: Proper case a string December 04, 2008 06:43PM |
John Marrone
Re: Proper case a string December 04, 2008 09:20PM |
Art Bonds
Re: Proper case a string December 05, 2008 12:45AM |
Chris L
Re: Proper case a string (in entry fields) December 14, 2008 05:35AM |
Jimbo
Re: Proper case a string (in entry fields) December 14, 2008 11:12AM |
Moderator |
Quote
Chris L
[Just noticed that this thread has continued on quite a bit since my previous contribution.]
Guenter
Sorry, but here I must take issue with you.
Just because a general condition does not apply in every single case should not prevent a general implementation.
You also seem to miss the point about title case, also called proper case. I can see no situation where I would want to apply this to a whole phrase or sentence. Forget the term 'title' case if this is confusing (the majority of English-language style guides now argue against the old practice of capitalising all major words in titles). Call it 'proper' case, the capitalisation of the first letter of names, places, addresses.
Sure there are names with irregular capitalisation. The most common occurrences in English names are of course the McDonnells and the O'Briens and such like. And we do have the occasional John de la Coursier or Richard van Otterdyk and so on.
But the vast majority of names and addresses in the English-speaking world, probably 95% plus, fit in with standard title case.
It is far easier to adjust the occasional entry of "non-standard" names such as those above than to have to manipulate the vastly greater number of standard names which a user enters without capitalisation or with mixed capitalisation because they have the Caps Lock on or have pressed the Shift key at the wrong time.
You suggest that proper case has no place in non-English languages. How then do you explain your own name Guenter Predl (proper case), your company Systemhaus Predl Informationstechnologie-GesmbH (proper case with one adjustment), and your address
Wehlistrasse 51 / 2 / 20, A-1200 Wien (all proper case)?
For further proof, just look back at the names of the contributors to this forum. Which of these do not conform entirely to proper case, ie capital first name, capital last name? Scrolling back through several hundred entries, I can only find one regular contributor: Piet van Z. If you go back through the thousands of entries on this forum you will also find one other 'van' and a 'de'. So even though you assert that more than 50% of the users of English-language WD are non native English speakers, 99% of their names conform to proper case without adjustment!
You also seem to suggest that because there are exceptions to a rule, because one cannot provide an algorithm which applies in every single instance (even 'Mac' can be problematic in English: some people are MacDonnell, some are Macdonnell), then there should be no accommodation for the 95%, perhaps 99% plus, majority.
My English-language version of WinDev has an entry mask for phone numbers. If I choose this, I get (+33)1.23.45.67.89. Huh? How many users in this forum can use this mask? (Yes, I realise it's for French phone numbers but there's also a separate entry mask for French phone numbers!)
If PC Soft are happy enough to include this mask, along with a mask for 'INSEE number' (along with 'INSEE number + key') -- what on earth is an 'INSEE number'?, and also obscure masks like 'Letter then Letter(CAPS)/Digit'), why can't they include a simple proper case? How hard can it be?
It is possible to create one's own custom mask but this option is very limited and are really only useful for a field with a very regulated format such as postal codes. Text options are limited and certainly it does not cater for something like proper case.
So I ask yet again - why can't PC Soft implement a simple proper case mask?
Chris L
Melbourne, Oz
Quote
So I ask yet again - why can't PC Soft implement a simple proper case mask?
Chris L
Re: Proper case a string (in entry fields) December 14, 2008 01:27PM |
Quote
My name / address consists of proper names and nouns and therefore it seems to you to be a fine example of 'proper case'. It is not. Because 'Predl Guenter', 'Wehlistrasse' and 'Wien' altogether are proper names, their first characters have to be capitalized under all circumstances.
Quote
I suggest that you write your own algorithm and supply your warnings about possible failure to your customer.