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

Pattern Match Uppercase, Lowercase 1

Status
Not open for further replies.

trenttc

Technical User
Feb 25, 2002
68
US
I want to print only the uppercase words from a field that starts with uppercase words followed by upper/lowercase words (ex: HI BOB Hi Bob > HI BOB). I uncheck File>Report Options>Database Server is Case-Insensitive. I would like to do this in a formula.
 
YOu can do this with a do while loop

whileprintingrecords;

local stringvar wordstr:='';
local numbervar n:=1;

While uppercase(left(stringfield), n)) = Wordstr
Do
(wordstr:= wordstr + (stringfield)[n];
n:=n+1;);

wordstr;


 
I created a formula with the code and the field on the report shows no data.

I understand that the uppercase function just converts whatever is there to uppercase. How does it work differently here?
 
If you're dealing with distinct words, then use SPLIT to separate the words. Then string them together again, but only if their value using the uppercase function is equal to their original function. It will be a bit long-winded but should work OK.

It helps to give your Crystal version - 8, 8.5, 9, 10, 11 or whatever. Methods sometimes change between versions, and higher versions have extra options.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Hard to know what you want, please include technical information as well as your descriptions.

For instance:

(ex: HI BOB Hi Bob > HI BOB) means what?

That you want greater than HI BOB to display, or?

You only want the uppercase portion of the string?

If just the uppercase, try:

whileprintingrecords;
stringvar output:="";
stringvar array TheWords:=join({table.field}," ");
numbervar x;
for x := 1 to ubound(TheWords) do(
if uppercase(TheWords[x]) = TheWords[x] then
Output := Output + TheWords[x] + " "
);
output

-k
 
Soirry, I think that should be:

whileprintingrecords;
stringvar output:="";
stringvar array TheWords:= split({table.field}," ");
numbervar x;
for x := 1 to ubound(TheWords) do(
if uppercase(TheWords[x]) = TheWords[x] then
Output := Output + TheWords[x] + " "
);
output

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top