cancel
Showing results for 
Search instead for 
Did you mean: 

A string can be at most 65534 characters long error

Former Member
0 Kudos

The following formula is causing the error.  How can I fix this formula to correct the error?

whileprintingrecords;

stringvar f:= f + {HNO_NOTE_TEXT.NOTE_TEXT};

Accepted Solutions (1)

Accepted Solutions (1)

former_member205840
Active Contributor
0 Kudos

Hi

Try this :

whileprintingrecords;

stringvar f:= f + {HNO_NOTE_TEXT.NOTE_TEXT};

If len(f) >= 65534 then

a:=a+{HNO_NOTE_TEXT.NOTE_TEXT};

else

f:=f + {HNO_NOTE_TEXT.NOTE_TEXT};

a&f;


Thanks,

Sastry

Former Member
0 Kudos

I ran the following formula and I'm still getting the same error.  Do you have any other suggestions?

whileprintingrecords;

stringvar f:= f + {HNO_NOTE_TEXT.NOTE_TEXT};


If len(f) >= 65534 then

stringvar a:=a+{HNO_NOTE_TEXT.NOTE_TEXT}

else

f:=f + {HNO_NOTE_TEXT.NOTE_TEXT};

a&f;

DellSC
Active Contributor
0 Kudos

I would try something like this:

whileprintingrecords;

stringvar f;

stringvar a;


If len(a) > 0 or len(f + {HNO_NOTE_TEXT.NOTE_TEXT} ) >= 65534 then

      a:=a+{HNO_NOTE_TEXT.NOTE_TEXT}

else

     f:=f + {HNO_NOTE_TEXT.NOTE_TEXT};

f & a

Be sure to initialize both f and a to empty strings in a section that comes before the one where you're using this formula.

-Dell

abhilash_kumar
Active Contributor
0 Kudos

Wouldn't this part of the code still throw the same error?

f & a

Both the variables f and a would make a combined string that is greater than the said limit.

-Abhilash

JWiseman
Active Contributor
0 Kudos

yes, you'd need to create a bunch of formulae to get around this...one main formula that creates a bunch of string running totals and then some display formulas. the display formulas would then be put into a Text Object.

the formula below uses a buffer (as mentioned below) of 500 characters...adjust this to the longest length of the note field...i.e. if the note field can be up to 2000 characters, then set b to 2000.

create a new formula like...

//@main formula

whileprintingrecords;

stringvar t:= {HNO_NOTE_TEXT.NOTE_TEXT};

numbervar b:= 500;

stringvar f1; stringvar f2; stringvar f3;

stringvar f4; stringvar f5; stringvar f6;

b:= 65534 - b;

if len(f1) <= b then f1:=f1+t

else

if len(f2) <= b then f2:=f2+t

else

if len(f3) <= b then f3:=f3+t

else

if len(f4) <= b then f4:=f4+t

else

if len(f5) <= b then f5:=f5+t

else

if len(f6) <= b then f6:=f6+t;

create another formula and put this in a text object...

//@display1 formula

whileprintingrecords;

stringvar f1;

create another formula and put this in the text object beside the above formula...

//@display2 formula

whileprintingrecords;

stringvar f2;

repeat the steps for creating new formulae 'til you've got one for stringvar f6;

if you want to reset the string running total on a Group level then also create a reset formula for the group header.

whileprintingrecords;

stringvar f1:= ''; stringvar f2:= ''; stringvar f3:= '';

stringvar f4:= ''; stringvar f5:= ''; stringvar f6:= '';

abhilash_kumar
Active Contributor
0 Kudos

Or, create an array as Ido suggests:

whileprintingrecords;
stringvar array arr;
numbervar i;
if i = 0 then i := 1;

if len(arr[i]) + len({HNO_NOTE_TEXT.NOTE_TEXT}) > 65534 then
(
i := i + 1;
redim preserve arr[i];
arr[i] := {HNO_NOTE_TEXT.NOTE_TEXT};
)
else
(
  arr[i] := arr[i] + {HNO_NOTE_TEXT.NOTE_TEXT}
);

And then create multiple formulae that refer to each index of the array like this:

Formula1:

whileprintingrecords;

stringvar array arr[1];

Formula2:

whileprintingrecords;

stringvar array arr;

if ubound(arr) > 1 then

arr[2];

Formula3:

whileprintingrecords;

stringvar array arr;

if ubound(arr) > 2 then

arr[3];

and so on...

-Abhilash

JWiseman
Active Contributor
0 Kudos

very nice, Abhilash. this is a much more elegant solution.

Former Member
0 Kudos

I'm getting the following error on the line below.  A subscript must be between 1 and the size of the array.  How can I fix this?

arr[i]

Line

if len(arr[i]) + len({HNO_NOTE_TEXT.NOTE_TEXT}) > 65534 then

abhilash_kumar
Active Contributor
0 Kudos

OK. Create this formula and place it on the Report Header:

whileprintingrecords;

stringvar array arr [1] := "";


-Abhilash

Former Member
0 Kudos

How should I adjust the following formula?  It is currently not working after I made the changes to fix the character error.

whileprintingrecords;
stringvar f;
global stringvar t:= f;
stringvar tok1:= 'PREOPERATIVE DIAGNOSES:';
stringvar tok2:= 'POSTOPERATIVE DIAGNOSES:';

numbervar ltok1:= length(tok1);
numbervar itok1:= instr(t, tok1);
numbervar itok2:= instr(t, tok2);

//trim(t[ltok1+itok1 to itok2-1])
if ltok1+itok1 > 0 and itok2 > 2
then trim(t[ltok1+itok1 to itok2-1])

JWiseman
Active Contributor
0 Kudos

hey Bobby,

i think that this reply should be for a different discussion.

-jamie

Answers (1)

Answers (1)

ido_millet
Active Contributor
0 Kudos

Test for string length to avoid reaching that limit.  Perhaps use an array.  Depends on your context.