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!
Erin LealeConsultant/ControllerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

peter57rCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mlmccCommented:
What part can be blank?

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

mlmcc
0
Erin LealeConsultant/ControllerAuthor Commented:
It can have a null which is the problem.  How would I take care of that in the original formula?   Thanks
0
mlmccCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.