Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: String Manipulation Post Reply Post New Topic
Author Message
WeirdAlchemist
Newbie
Newbie


Joined: 31 Oct 2007
Online Status: Offline
Posts: 3
Quote WeirdAlchemist Replybullet Topic: String Manipulation
    Posted: 31 Oct 2007 at 2:16pm
I have a variable length space delimited long string in this format:

Word1 Word2 Word3 Word4 Word5....

My CR text field is N characters long
I wish to make a newline (don't want to use 'will grow') by replacing
a space character with a CHR(13), the closest space that's < N.

i.e.

Word1 Word 2 Word3
Word 4 Word 5

How can I find and replace that space character?

Thanks
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 31 Oct 2007 at 4:06pm
Try something like this:
NumberVar lastSpace;
StringVar text;

 
If length({table.field}) > N then
  lastSpace := InStrRev(Left({table.field}, N), ' ');
  text := left({table.field}, lastSpace) + chr(13) +
     mid({table.field}, lastSpace-1);
else
  text := {table.field};
text
 
-Dell


Edited by hilfy - 31 Oct 2007 at 4:07pm
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.016 seconds.