x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1050

# How do I limit the number of characters returned in a variable.

I am receiving the following error with this formula in Crystal XI.

A string can be at most 65534 characters long.

How do I limit the number of characters returned?

``````Here is the formula that the report is bombing out on.

whileprintingrecords;
stringvar x:=x+{Database.NOTES}

Type = String and Length is 1000
``````
0
angeleam
• 4
• 3
1 Solution

Commented:
Do you need to display the full string even if it is over 64K?

You can do this

If Len(x) < 64533 then
x := x + {Database.NOTES}

If you need to display the full string there are ways using arrays of strings.

mlmcc
0

Author Commented:
I don't need to print if it is over 64. when I use this formula I receive an error: The ) is missing. and it highlights (x)
0

Commented:

whileprintingrecords;
stringvar x;
If Len(x) < 64533 then
x := x + {Database.NOTES}

mlmcc
0

Author Commented:
I left out the ;. I think this formula will work for me. Thank you for your reply.
0

Author Commented:
After validating my data how would display the text if it is over 65534?
0

Commented:
If it is over 64K then you need to use an array of strings.

whileprintingrecords;
stringvar array x := [""];
numbervar currentindex := 1;

If Len(x[currentindex]) < 64533 then
x[currentindex] := x[currentindex] + {Database.NOTES}
else
(
currentindex := currentindex + 1;
ReDim Preserve x[currentindex];
x[currentindex] := x[currentindex] + {Database.NOTES};
);

To display you will need several display formulas
First String
whileprintingrecords;
stringvar array x;
x[1]

second string
whileprintingrecords;
stringvar array x;
numbervar currentindex;
If currentindex > 1 then
x[2]

thrid string
whileprintingrecords;
stringvar array x;
numbervar currentindex;
If currentindex > 2 then
x[3]

mlmcc

0

Author Commented:
Thank You
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.