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

cr 8.5 - string quirk

Status
Not open for further replies.

leburg

Programmer
Feb 15, 2006
64
US
I have a string that I need to hack up based on * delimiters. There could be up to five fields, 4 asterisks, or less, if there is 3 *s then only the first 4 fields get filled, and so on. I have worked out the logic to break up the string, it's would go good with some marinara sauce, but it works.

How I got here. Basically, I converted a memo field via a view, cutting it down into 2 255 char length strings using a substring function. Had I left it in one piece, and it happens to be greater than 255 char length, it would be too long to manipulate further, crashing on string length limitation in Crystal. All this works well for what I needed to do. Is there an easier way, I'm sure, always is.

Okay, now the quirk I have has me thinking that one of these strings may at times contain a control character, one I'm not seeing but suspect a carriage return, line feed, and I wondered if a string can be scrubbed of such a character?

Any thoughts? Many thanks.
 
Hi,
You can use the Replace function with the chrW() value of those characters:

For Line Feed try:

Replace({string_field},chrW(10),"")

and for CR try:

Replace({string_field},chrW(13),"")

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Depending upon your datasource, you might have been able to use a SQL expression instead of a view, as in:

{fn substring(`table`.`memo`,1,255})

or, depending upon your datasource:

substr(`table`.`memo`,1,255)

Then you could have used a formula to split the result--one formula per field, as in the following for the second element:

stringvar array x := split({%memosubstr},"*");
if ubound(x) >= 2 then
replace(replace(x[2],chr(13),""),chr(10),"")

-LB
 
Great. I'm learning something. Great. Never used an SQL expression. So I take it I do this inside crystal, I choose new SQL expression in Field explorer box. Doed it, however the 'memo' field I would like to convert and manipulate, now on the fly, does not appear as a field within the table, it simply vanishes. I see it, the memo field, in the field explorer, but inside the create an SQL expression field selection box, I don't...?

I'll try the array breakup now...that looks so much leaner than the hack job I worked up.

What you figure? Thanks. (using 8.5)
 
Yes, forgot to mention that the memo field won't be in the field list--you have to manually type it in, but it will be accessible to the expression once you've done that.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top