Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Strip out a carriage return from string Post Reply Post New Topic
Author Message
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Topic: Strip out a carriage return from string
    Posted: 20 Nov 2014 at 3:27am
I have a string field where several of the values contain carriage returns or something that is causing a line break when I export out the report to a CSV. I need to strip out whatever is causing this to happen.

The field is table.billing_address

My initial thought was to create a formula field to replace the carriage return with "", but I cannot figure out how to do that.

Has anyone else encountered this before? Ideas for solving this problem?
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 20 Nov 2014 at 4:16am
Found a solution. I will share it here in case anyone else has the same problem.

Created a new Formula:

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.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Nov 2014 at 4:17am
REPLACE(replace({table.billing_address},CHR(13)," "),CHR(10)," ")
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 20 Nov 2014 at 4:32am
DBlank,

Thanks for the response. I didn't know about CHR values until today. I found a list of special characters to use as a reference in the future:
Character 8 - Chr(8): Backspace
Character 9 - Chr(9): Tab (vbTab)
Character 10 - Chr(10): Line Feed Return (vbLf)
Character 11 - Chr(11): Shift+Enter (vbVerticalTab)
Character 12 - Chr(12): Page Break (vbFormFeed)
Character 13 - Chr(13): Carriage Return
Character 14 - Chr(14): Column Break
Character 15 - Chr(15): Shift In
Character 32 - Chr(32): Space

Do you know of a good resource I can bookmark to reference for other special characters?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Nov 2014 at 7:32am

you can search ASCII charts to get a list

IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.051 seconds.