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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Smart Propercase logic 1

Status
Not open for further replies.

cspuckett

IS-IT--Management
Feb 6, 2009
27
US
Is there a way to include logic in a propercase scenario where some words do not get adjusted?

For example, let's take two vendors:
HARDWARE SUPPLY SHOP
ABC HARDWARE USA, INC.

Propercase will turn them into:
Hardware Supply Shop (this is good)
Abc Hardware Usa, Inc. (this is "okay")

Prefer:
ABC Hardware USA, Inc.

I'm lucky with this report in that I know the keywords I would not want to change. For example, I know if "ABC" or "USA" then don't propercase the word, otherwise, propercase is fine.

I'm guessing some sort of substring and array logic would be the solution...but not sure how to do that (if that's the solution). Any thoughts?
 
This will work with the examples you have provided but as you can see I needed to test for 'USA,' (note the comma) for it to work correctly so you may need to check for other combinations or remove any non alphabetic characters before splitting the string

Code:
Local stringvar Array Temp := Split({Vendor}, ' ');
Local Numbervar i;

For i := 1 to Count(Temp)
Do(
If Not(Temp[i] In ['ABC', 'USA', 'USA,']) Then
    Temp[i] := ProperCase(Temp[i]));

Join(Temp, ' ')

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Genius! Worked like a charm just like you coded it. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top