>I used the PROPER() function in FPD 2.6 reports. I would like to know if I can use it in a VFP 5.0 form to display the first letter of a word in upper case and the rest of the letters in lower case. If possible where do I use the function.
>
>Thanks in advance.
>
>Petrus.
Hi all, I was unluck as I do not realize that there is a proper function in VFP!
I have written by myself as following code(UpCaption.prg).
After I found the proper() function, and compare with my version, I found sth that proper() do not work well!!
- other than space, most letter after special symbol will not give Caption Letter!
e.g. Proper("r.d.(relationship diagram)") will give:
R.d.(relationship Diagram)or more simple fail case: Proper("u.s.a.") will give:
U.s.a. Then, you will know how problem comes if user want the customer address in Proper Case Format for letter or label usage!!!
(Forgive me to use Country Name as example!)
So, I would prefer to use my version and availible to add some special cases to ignore... such as "e.g.", middle conjuction " and ", e.t.c.
Of cos, there is a very special case in following code:
All the ' mark is not included as most cases are:
"haven't", "Peter's" ...
^_^; Good Luck!
* UpCaption()
* Change the line into Proper Case
* Usage: Rline = UpCaption(LLINE)
* FUNCTION UPCAPTION
LPARAMETERS PLINE
IF PCOUNT() < 1
RETURN ""
ENDIF
LLINE = ALLTRIM(LOWER(STRTRAN(PLINE,' ',' ')))
LLEN = LEN(LLINE)
RLINE = ""
IF LLEN>1
RLINE = UPPER(LEFT(LLINE,1)) && TAKE 1ST CHAR
LLINE = SUBSTR(LLINE,2) && LLINE REMAIN
DO WHILE !EMPTY(LLINE) .AND. LEN(LLINE) > 1
LASTCHAR = RIGHT(RLINE,1) && LASTCHAR OF RLINE
THISCHAR = LEFT(LLINE,1) && 1STCHAR OF LLINE
DO CASE
CASE EMPTY(THISCHAR) && UPPERFLAG .T.
RLINE = ALLTRIM(RLINE) + " "
CASE LASTCHAR $ '~!@#$%^&*()_+|{}:"<>?`-=[];,./\' .OR. EMPTY(LASTCHAR) && UPPER CASE
RLINE = ALLTRIM(RLINE + UPPER(THISCHAR))
OTHERWISE && MIDDLE
RLINE = ALLTRIM(RLINE + LOWER(THISCHAR))
ENDCASE
* LLINE = RIGHT(LLINE,LLEN-1)
LLINE = SUBSTR(LLINE,2)
ENDDO
LASTCHAR = RIGHT(RLINE,1) && LASTCHAR OF RLINE
THISCHAR = LEFT(LLINE,1) && 1STCHAR OF LLINE
DO CASE
CASE EMPTY(THISCHAR) && UPPERFLAG .T.
RLINE = ALLTRIM(RLINE) + " "
CASE LASTCHAR $ '~!@#$%^&*()_+|{}:"<>?`-=[];,./\' .OR. EMPTY(LASTCHAR) && UPPER CASE
RLINE = ALLTRIM(RLINE + UPPER(THISCHAR))
OTHERWISE && MIDDLE
RLINE = ALLTRIM(RLINE + LOWER(THISCHAR))
ENDCASE
RLINE = ALLTRIM(RLINE)
RETURN RLINE
ELSE
RETURN ""
ENDIF
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.