views:

3157

answers:

1

In my crystal report, I noticed one of the fields being pulled from a table has special characters. More specifically carriage returns and tabs. Is there a way to strip this out, so it doesn't show up blank in my reports?

Thanks in advance.

+3  A: 

This should do it:

stringvar output := {TABLE_NAME.FIELD_NAME};
output := Trim(output);  //get rid of leading & trailing spaces
output := Replace(output,Chr(13),'');  //get rid of line feed character
output := Replace(output,Chr(10),'');  //get rid of carriage return character

//add any other special characters you want to strip out.

If you have a lot of characters to strip out, you can use this slightly fancier approach. Just add whatever characters you want to strip out to the in[]:

stringvar input := {DROPME.TEST_FIELD};
stringvar output := '';
numbervar i;

input := Trim(input);

for i := 1 to Length(input) Step 1 do
  if not(input[i] in [Chr(13),Chr(10)]) then
    output := output + input[i];

output
JosephStyons
awesome.. it works. thanks!
phill