Danny Reader

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?

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?

ASKER CERTIFIED SOLUTION

membership

This solution is only available to members.

To access this solution, you must be a member of Experts Exchange.

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

UBound(x) or Count(x) both return the number of elements in an array

ASKER

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!

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

ASKER

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!