×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

how to split sentence text to wrap properly.

how to split sentence text to wrap properly.

how to split sentence text to wrap properly.

(OP)
Hi,

Crystal Reports 2011 SP7. I have an report input parameter where the user can enter text. The desired presentation is to show the text as indented bullet items. Since the Crystal Input Parameters do not support multiple line input parameters, I devised a scheme to have the user precede each bullet line with a plus sign character. I have a formula that uses the replace function to replace the plus sign with Carriage Return, Carriage Return, Tab, Bullet, Tab.

CODE -->

Replace({?bullet_input}, "+", ChrW(13) + ChrW(13) + ChrW(9) + ChrW(9679) + ChrW(9)) 

This works great, however, if the bullet text wraps to the next line, the next line's text does not indent to where the bulleted text begins.

For example:
Input text:
+ Try a thing you haven’t done three times. Once, to get over the fear of doing it. Twice, to learn how to do it. And a third time, to figure out whether you like it or not. + Courage is not the absence of fear, but rather the judgement that something else is more important than fear.

Desired output:
  • Try a thing you haven’t done three times. Once, to get over the fear of doing it. Twice, to learn how to do it. And a third time, to figure out whether you like it or not.
  • Courage is not the absence of fear, but rather the judgement that something else is more important than fear.
Actual Report Output:

____+_Try a thing you haven’t done three times. Once, to get over the fear of doing it. Twice, to learn how to do it. And a third time, to figure out whether you like it or not.
____+_Courage is not the absence of fear, but rather the judgement that something else is more important than fear.

NOTES:
1. See how the wrapped bulleted text does not align below the text above it, it left justifies.
2. I used underscores to represent spaces and plus signs to represent bullets since the HTML in this forum will not display these characters.

I think I need to Split the text for each bullet on a space character based on the maximum number of characters that can fit on a bulleted line. In my case the bullet line wraps at 95 characters, so I think I need to find the last space in the text at less than 95 and insert a CR and a couple TABS.

I appreciate any suggestions on how to implement this.

P.S. I can't believe that Crystal Reports does not support multiple line text input.

Thanks,

RE: how to split sentence text to wrap properly.

Hi Statey,

Have you got the solution please share , similar i am facing.

Regards
Bala

RE: how to split sentence text to wrap properly.

Similar Question here.
http://www.tek-tips.com/viewthread.cfm?qid=1783548

The other possibility as I suggested is to remove bullets, place text in a indented text box and then use wingdings to show a bullet in a free standing text box.

Ian

RE: how to split sentence text to wrap properly.

Hi Ian,
I asked Statey whether he had solution to share.

Even i remove bullet and then free standing text box will work a fixed lines. But I am trying to build a resume layout where the input text paragraph/sentence with bullets are not of fixed length or fixed lines it depends individual resume per person.

Regards:
Bala

RE: how to split sentence text to wrap properly.

(OP)
I got this working........

Background
For bulleted items, user precedes each bullet with a Plus Sign [+] character. NOTE: Due to Crystal parameter screen limitation of not allowing multiple lines of text in a string parameter, the user must concatenate all lines of input text into a single line and then paste into the parameter textbox. I also added the capability for the user to use a Tilde [~] character to denote a Linefeed. I added WrapLength to determine a point at which to wrap the text to the next line. The involved having to break up the input text into an array of words.

Here is my formula.

//------------------------------------------------------------------------------------------
// Formula: 2nd_sentence_with_determination
//------------------------------------------------------------------------------------------
// Append the text selected for the Determination parameter to the Determination sentence text.
// Text will be a numeric bulleted list. A plus sign [+] will denote a bullet item.
// Used numbered bullets unless only one, then use a circular bullet.
//------------------------------------------------------------------------------------------
Local StringVar sentence_text;
Local StringVar determ_text;
sentence_text := "After completion of the investigation a founded determination was made. The ";
sentence_text := sentence_text + {?reason_reasons} + " for this determination ";
if ({?reason_reasons} = "reasons") then
(
sentence_text := sentence_text + "are: ";
)
else
(
sentence_text := sentence_text + "is: ";
);
//---------------------------------------------------------------------------------------
// Determination Reason(s)
//---------------------------------------------------------------------------------------
// If Plus Sign [+] detected, format bulletted text
// If Tilde [~] detected, replace tilde with CR, CR, TAB
//------------------------------------------------------------
// CARRIAGE RETURN: ChrW(13), TAB: ChrW(9), BULLET: ChrW(9679)
//---------------------------------------------------------------------------------------
NumberVar TotalInputLength;
NumberVar BulletSectionBgn;
NumberVar BulletSectionEnd;
StringVar bullet_section;
StringVar non_bullet_section;
StringVar non_bullet_text;
BooleanVar bNoBulletSection;


TotalInputLength := Length({?determination_reasons});

// Get position of 1st Plus Sign [bullet bgn marker]
BulletSectionBgn := InStr({?determination_reasons}, "+");

// Get position of Equal Sign [bullet end marker]
BulletSectionEnd := InStr({?determination_reasons}, "=");
If BulletSectionEnd = 0 then
BulletSectionEnd := TotalInputLength;

If BulletSectionBgn > 0 then
bullet_section := Mid({?determination_reasons}, BulletSectionBgn, (BulletSectionEnd - BulletSectionBgn)+1);

if BulletSectionBgn > 0 then
(
// format bulletted text
StringVar all_text;
StringVar bullet_text;
NumberVar Idx;
NumberVar x;
NumberVar BulletLen;
NumberVar NewBulletLen;
StringVar new_bullet_text;
StringVar array bullet_array;
StringVar array word_array;
NumberVar BulletCount;
NumberVar WordCount;
NumberVar WrapLen;
NumberVar Pos;
StringVar Rules;
StringVar BulletType;
StringVar LineFeedVal;
NumberVar NumLFsBetweenBullets;
StringVar LineFeeds;
NumberVar WrapLength;

WrapLength := 100;
NumLFsBetweenBullets := 2;

// put the entire input into the all_text variable
all_text := bullet_section;

LineFeeds := "";
For Idx := 1 To NumLFsBetweenBullets Do
(
LineFeeds := LineFeeds + ChrW(13);
);

bullet_array := split(all_text, "+");

BulletCount := count(bullet_array);

// Loop – break up all_text into individual lines (prefaced with plus sign)
For Idx := 1 To BulletCount Do
(
WrapLen := 0;
// If only one bullet, just use a round bullet //12/28/2017
If BulletCount = 2 then
(
new_bullet_text := LineFeeds + ChrW(9679) + ChrW(9);
)
else
(
new_bullet_text := LineFeeds + totext(Idx-1, 0, "") + "." + ChrW(9);
);

BulletLen := Length(bullet_array[Idx]);
If BulletLen > 0 then
(
word_array := split(bullet_array[Idx], " ");
WordCount := count(word_array);
For x := 1 To WordCount Do
(
new_bullet_text := new_bullet_text + word_array[x] + " ";
NewBulletLen := Length(new_bullet_text);
If x < WordCount then
(
If (NewBulletLen + Length(word_array[x+1]) - WrapLen) >= WrapLength then
(
WrapLen := NewBulletLen - Length(word_array[x+1]);
new_bullet_text := new_bullet_text + ChrW(13) + ChrW(9) + " ";
)
)
);
Bullet_text := Bullet_text + new_bullet_text;
)
);
Bullet_text := Replace(Bullet_text,"~", ChrW(13) + ChrW(13) + ChrW(9));
sentence_text := sentence_text + Bullet_text;

If TotalInputLength > BulletSectionEnd then
(
// Append any remaining text to the bulleted text
non_bullet_section := Mid({?determination_reasons}, BulletSectionEnd, (TotalInputLength - BulletSectionEnd)+1);
non_bullet_text := Replace(non_bullet_section, "=", ChrW(13));
non_bullet_text := Replace(non_bullet_text, "~", LineFeeds);
sentence_text := sentence_text + ChrW(13) + non_bullet_text;
)
)
else
(
sentence_text := sentence_text + Replace({?determination_reasons},"~", ChrW(13) + ChrW(13) + ChrW(9));
);

sentence_text := ChrW(13) + sentence_text;

RE: how to split sentence text to wrap properly.

Hi Statey,
Thanks. I will try.

Regards:
Bala

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close