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!

Proper Case with Exceptions

Status
Not open for further replies.

RunnerDan

IS-IT--Management
Jul 16, 2002
9
US
I know how convert something to proper case, i.e., MRS. JONES, CPA to Mrs. Jones, Cpa. But I would like to have a list of exceptions that would not be converted, in the example, CPA should not be converted, any ideas?
 
You can hardcode the exceptions into a formula, perhaps using IF's:

local stringvar MyField := {MyTable.MyField};

MyField := Replace(MyField, "Search text", "New Text");
MyField := Replace(MyField, "Other Search text", "Other New Text");

MyField

You can use IFs to minimize the number of checks if you know that you'll only have one of the conditions per string.

You can do a test using instr first, but since you already have to look at each field, you might as well just launch the replaces.

-k kai@informeddatadecisions.com
 
I like SV's approach except that it isn't really complete...for example: What if we had CPA, CPa, Cpa or cpa

these are 4 different searches when only one is needed.

Also you can set up an array in a formula hidden in the report header to assign not only the search criteria but also the replacement value....I'll show you.

Let us say we want the following spellings to be exactly like this

PhD, CPA, BSc

Create an assignment formula

******************************************

@ExactSpellings (place suppressed in the report header)

WhilePrintingRecords;
stringVar array spellings := ["PhD","CPA","BSc"];
//add this since the result of a formula cannot be an array
" ";

******************************************

Now in the formula that prints the name or whatever do this

******************************************

@DisplayCorrectSpelling

WhilePrintingRecords;
stringVar array spellings;
stringVar MyField := {Table.textstring}
numberVar icount;
numberVar iPos;

for icount := 1 to ubound(spellings) do
(
iPos := instr(uppercase(Myfield),
uppercase(spellings[icount]))
if iPos <> 0 then
Myfield := left(Myfield,iPos -1) +
spellings[icount] +
right(Myfield,length(Myfield) -
iPos - length(spellings[icount]) + 1);
//if you are only replacing one exception
//you could &quot;Exit For&quot; at this point By adding it to
//a block of if statements above
);

Myfield;

******************************************

this would have to be modified if there was more than one instance of the exception in a field but it doesn't look to be the case here.

There you go...only maintenance required is to the @ExactSpellings formula in the report header....I would personally use a background of red so that it sticks out in design (the formula would have a conditional suppress using the formula

1 = 1

This way it always suppresses but Crystal will maintain the color in design.

hope that helps Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top