Link to home
Start Free TrialLog in
Avatar of Danny Reader
Danny ReaderFlag for United States of America

asked on

How to count array size when using split function?

I have a field (FullNameField) with various name formats:

Mr. John Smith
Mrs. Sally E. Jones
Rick Stevens
Pat Allen Williams

I can use the following formula to separate and identify the various parts of the name:

stringVar array x;
x := Split({FullnameField});
x[1]; //output first array element

I want to create new fields for Title, First Name, Middle Name, Last Name.  Is there a way to count the total number of array elements so it can be determined which field it should go in?
Avatar of Mike McCracken
Mike McCracken

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Danny Reader


Finding the last element in the array won't help me.

If I can find out how many total elements are in the array along with a check to see if the first element is Mr. Mrs. or Ms. then I can determine if my Title formula should be the first array element or blank.  Then my First Name formula would display the first array element only if it is not Mr. Mrs. or Ms. etc.

At least that's the plan, I just need to get the array size for each name and I'll see if this could work.  Any suggestions on another approach would be greatly appreciated.  Thanks!
mlmcc has already given you the way to find out how many elements are in an array

UBound(x) or Count(x) both return the number of elements in an array
Thansk mlmcc, I should have read your suggestion more closely...the answer was there.  I initially tried x[UBound(x)] to get the last name.

UBound(x) is indeed the solution.  Thanks again!