Print Page | Close Window

Bracket problem

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=15590
Printed Date: 03 May 2024 at 6:53am


Topic: Bracket problem
Posted By: JohnS
Subject: Bracket problem
Date Posted: 09 Feb 2012 at 10:40pm
DESCRIPTION:
In Crystal Reports v11 we build a report. This report contains a VarChar2 database field. The string from the database is too long to fit in one line of the field, so it breaks somewhere at the end of the “visible” string (the right side of the text field). The part after the line break is shown on the second line in the field. So far, so good (example 1).
Now we have a string which contains a closing and an opening bracket. In this scenario the string will break exactly between the closing and an opening bracket. Even if the brackets are at the beginning of the string. In that case the line space on the first line is hardly used (example 2). This scenario is valid for both round and square brackets and a combination of bracket types.
 
Example 1
------------------------
Original string without brackets:
“This is a long string. This is a long string. This is a long string. This is a long string. This is a long string. This is a long string. This is a long string. This is a long string.”
 
Actual and expected appearance in text field:
“This is a long string. This is a long string. This is a long string. This is a long string. This is a long
string. This is a long string. This is a long string. This is a long string.”
------------------------
 
Example 2
------------------------
Original string with brackets:
“This is a (long)(string). This is a long string. This is a long string. This is a long string. This is a long string. This is a long string. This is a long string. This is a long string.”
 
Actual appearance in text field:
“This is a (long)
(string). This is a long string. This is a long string. This is a long string. This is a long string. This is a long string. This is a long string. This is a long string.”
 
Expected appearance in text field:
“This is a (long)(string). This is a long string. This is a long string. This is a long string. This is a
long string. This is a long string. This is a long string. This is a long string.”
------------------------
 
QUESTION 1:
In the second example, what can we do to make the line break as in the “Expected appearance”?
 
QUESTION 2:
Are there any more characters for which this scenario (example 2) is valid?
 
 



Replies:
Posted By: rkrowland
Date Posted: 09 Feb 2012 at 11:09pm
You could try making a formula like the following and using that in your details section rather than the database field;
 
Replace({table.longstringfield},ChrW(13),"")
 
Let me know how it goes and if it works as I'm not certain it will.
 
Regards,
Ryan.


Posted By: JohnS
Date Posted: 09 Feb 2012 at 11:38pm
Hi Ryan,
 
Unfortunately, this isn't the solution. It still shows the same problem.
 
The string containts no white spaces, it looks like this:
 
29~32<n>,X,+X,+2,+5,+8,del(18)(q24),+13,+18,+19,+21,+22[cp6]/52~62<2n>,XY,+X,+1,+5,+8,del(10)(q26)x2,+13,+17,+18,+19,+19,+21,+21,+22,+22[cp7]/46,XY[14]
 


Posted By: rkrowland
Date Posted: 10 Feb 2012 at 12:25am
Hmm it's caused because a close bracket is classed as sort of a space which Crystal thinks is ok to put a linebreak after when there's no other available spaces.
 
There's 2 ways around it, you can replace all the brackets with a character which Crystal won't allow spaces after, or you can insert your own spaces for Crystal to use which would make it use up a lot more of the available space.
 
I'd probably do the following;
 
replace({table.longstringfield},",",", ")
 
Regards,
Ryan.
 
EDIT: If you didn't want to insert spaces after every comma you could also determine a number of characters to show on 1 line and insert a space after that many characters, eg;
 
left({table.longstringfield},100)
& " "
& mid({table.longstringfield},101,100)
& " "
& mid({table.longstringfield},201,100)
 
Just keep adding to that if your fields are longer than 300 characters.
 
Hope the above helps.



Print Page | Close Window