Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

First letter uppercase 1

Status
Not open for further replies.

keepingbusy

Programmer
Apr 9, 2000
1,470
GB

All, I should know this but cannot remember the command. It was previously posted on Tek-Tips but I cannot find it. The command:
Code:
ISUPPER(cExpr) determines whether the left most character of the specified character expression is an uppercase alphabetic character.
But I want to convert the left most character of a variable so for example:

myvarforname could contain john
myvarsurname could contain davies

If I put them together: trim(myvarforname)+" "+trim(myvarsurname) would produce: john davies

I want the end result as John Davies

Many thanks

Lee
 
Lee,

You have to use PROPER(), but you need to apply it to each individual word. Something like this:

Code:
lcText = .... your text here
lcNewText = ""
FOR lnI = 1 TO GETWORDCOUNT(lcText)
  lcNewText = ;
    lcNewText + PROPER(GETWORDNUM(lcText, lnI)) + " "
ENDFOR

Actually, that's not completely correct. Any word delimiters other than single spaces won't be properly carried to the output. But it should give you the general idea.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Mike

Saved the day as always!

By putting two fields in a table together such as:
Code:
proper(trim(forname))+" "+proper(trim(surname))
that resolved the issue.

May be an easy one Mike, but very worthy of a star.

Thanks again

Lee

Windows Vista
Visual FoxPro Versions 6 & 9
 
Proper() function automatically puts words in the proper case (words divided by space), no need for extra processing.
 
True Markos, to be more precise, words divided by white space, which includes chr(9) and also chr(13) and chr(10). What it doesn't account for is cases like McScottish or O'Neill, there are better variants of the Proper functions for names.

See faq184-4320 for an example.

Bye, Olaf.
 

Hello Olaf
What it doesn't account for is cases like McScottish or O'Neill, there are better variants of the Proper functions for names.
This issue has been resolved but what are the better variants for names like the ones you have mentioned? This might be useful for the future.

Lee
 
Take a look at the Trueproper User Defined Function too. It might need to be tweaked to fit your needs, but provides a little more flexibility.

You can see an example in the FAQ section: faq184-4320

Jim Osieczonek
Delta Business Group, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top