on 03-16-2015 4:15 AM
I've got a formula in a Group Footer that concatenates the Group Header results. When I display it, however, the text wrapping cuts off words at the width of the text box. I've checked Can Grow, but can't really widen the text box due to the constraints of the layout. Here's my example:
GH2 Jenny
GH2 Jonny
GH2 Penny
GH2 Sally
GH2 Michael
GF2 Jenny, Jonny, Pe
nny, Sally, Micha
el
Is there any way to control the text wrapping so that it only breaks on a word? Thanks!
Hi Ahren,
Here's what you need to do:
1) Create another text object of the same width and count the maximum number of letters that can fit
2) It is advisable that you use a fixed width font like Courier New. If you can't however, you could count by using a letter that takes the most space - example W, X or Z.
3) You would then fill up the text object with either of these characters and this will help you count the letters that can fit in that space
4) Create a formula with this code:
stringvar s := {string_field_or_formula_variable};
local stringvar array arr := split(s," ");
local numbervar i;
numbervar lcount;
lcount := 1;
local numbervar fixed := 13; //Replace this number with the letters you counted that can fit in the text object
local booleanvar nl := false;
for i := 1 to ubound(arr) do
(
If i = 1 then
(
local stringvar nstring := nstring + trim(arr[i]) + " ";
local numbervar rem := fixed - len(nstring);
)
else if i <> 1 and i <> ubound(arr) then
(
if len(arr[i]) <= rem then
(
nstring := nstring + trim(arr[i]) + " ";
rem := (fixed*lcount) - (len(nstring)+lcount);
stringvar s := nstring;
numbervar t := rem;
)
else
(
nstring := rtrim(nstring) + chr(13) + trim(arr[i]) + " ";
lcount := lcount + 1;
nl := true;
rem := (fixed)- len(arr[i] + " ");
)
)
else if i = ubound(arr) then
(
if len(arr[i]) <= rem then
(
nstring := nstring + trim(arr[i]);
rem := fixed - len(nstring);
)
else
(
nstring := nstring + chr(13) + trim(arr[i]);
rem := fixed - len(arr[i] + " ");
)
)
);
nstring;
Note: Line #6 is where you would type in the number of letters that can fit
5) Make sure 'Can Grow' is enabled
Hope this helps.
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhilash,
Thanks again for the response. The formula that was cutting the text was {MyFormula} in GF2. I made a new formula with your text above, replacing line 1 with:
stringvar s :+ {MyFormula}
In line 6, I made the number of characters to count 18. I put the formula in GF2, next to the original {MyFormula}. When I preview, they look identical. I went back into the formula and changed the character count on line 6 to many different variations (I tried 10, 13, 20, and 28), and it always looks identical to the original {MyFormula}. What am I missing?
Thanks!
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.