subscript must be between 1 and the size of the array -

Here is my formula - (thank you mlmcc) -

Local StringVar Array strLineParts;
Local NumberVar index;
Local StringVar strOutput;

strLineParts := Split({@ExtItem},'!');
For index := 2 to UBound(strLineParts) do
    strOutput := strOutput & strLineParts [index] & ' ';

strOutput := strOutput & chr(13) & strLineParts [1];

strOutput


I think it is having an issue when the field it blank.  I get the array error - I tried adding if (isnull({field}) then "" else the rest of the formula but it is not working.

Can you help?  

Thank you!
elealeAsked:
Who is Participating?
 
peter57rConnect With a Mentor Commented:
You will get an error if {@Extem} is empty or if it has text but no !

Assuming that you just want to output the value in both of these circumstances then do..

strLineParts := Split({@ExtItem},'!');
if Ubound(strLineParts)>1 then
(
For index := 2 to UBound(strLineParts) do
    strOutput := strOutput & strLineParts [index] & ' ';
 strOutput := strOutput & chr(13) & strLineParts [1];
)
else
strOutput := {@ExtItem};

strOutput
0
 
mlmccCommented:
What part can be blank?

Is it the formula @ExtItem or can it have a NULL part?

mlmcc
0
 
elealeAuthor Commented:
It can have a null which is the problem.  How would I take care of that in the original formula?   Thanks
0
 
mlmccConnect With a Mentor Commented:
What is the original formula?

Assuming the full result could be NULL

Local StringVar Array strLineParts;
Local NumberVar index;
Local StringVar strOutput;
Local StringVar strLocal;

strLocal := {@ExtItem};
If Not IsNull(strLocal) then
(
    strLineParts := Split({@ExtItem},'!');
    if Ubound(strLineParts)>1 then
    (
     For index := 2 to UBound(strLineParts) do
        strOutput := strOutput & strLineParts [index] & ' ';
     strOutput := strOutput & chr(13) & strLineParts [1];
    )
    else
      strOutput := {@ExtItem};
)
else
    strOutput := "";

strOutput

mlmcc
0
All Courses

From novice to tech pro — start learning today.