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

In concatenation, how to decide where line break happens

Status
Not open for further replies.

smitty691

Technical User
Jul 24, 2003
24
US
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...
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top