×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*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.

In concatenation, how to decide where line break happens

In concatenation, how to decide where line break happens

(OP)
Hi all...

I have a list of names...
Brian P. Bennett
Mario Puzo
Hugh E. Hefner
Lucy Arnez

I have used the following code to concatenate them...

WhilePrintingRecords;
Shared StringVar ConCat;
If ConCat = "" then ConCat := {table.field}
else if not({table.field} in ConCat) then ConCat := ConCat + ", " + {table.field}

...and I have the 'Can Grow' checked on the display field so now I get:

Brian P. Bennett, Mario Puzo, Hugh
E. Hefner, Lucy Arnez

Is there a way I can make the report keep Hugh E. Hefner together?

I'm using CRXI, if that matters...

RE: In concatenation, how to decide where line break happens

This seems to work. I arbitrarily used 30 as the cutoff for the length of the concatenation per line, but you could use whatever length you like (change in both places)--except that the formula object must be stretched beyond that length or it will automatically wrap. Replace {@Name} with your name field.

WhilePrintingRecords;
Shared StringVar ConCat;
numbervar cnt;
numbervar i;

for i := 1 to len(Concat) do (
if remainder(len(concat),30)=0 then
cnt := 1 else
cnt := cnt + 1
);
if not({@Name} in ConCat) then
(
if onfirstrecord then
concat := concat + {@Name} else
if not onlastrecord and
len(previous({@Name})) + len({@Name}) < 30 then
ConCat := ConCat + ", "+{@Name} else
concat := concat + ", " +chr(13)+{@Name}
);
concat

-LB

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.

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:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!