Hello!
I am trying to split data using the Split function and pull out specific portions of the array. Once my data is split and I try to pull out a specific section, I receive an error stating "Execution Error:Runtime Error: Out of Bounds."
The code below works and pulls out the first section of data.
var txt = $feature["C1_BASIS"];
var arr = Split(txt, ";");
return arr[0]
However this block of code returns the out of bounds error when I try and pull out the next section of data.
var txt = $feature["C1_BASIS"];
var arr = Split(txt, ";");
return arr[1]
How can I return the individual sections of my split?
Thanks!
Hi David Krady,
What is the length of your array, i.e. how may items does your array contain?
Some investigation:
If there is no second item in your array, then the error message is correct.
I wrote a small script to test:
var txt = "person1;person2;person3";
var arr = Split(txt, ";");
//return Count(arr)
return arr // expected output [ person1 , person2 , person3 ]
//return arr[0] // expected output person1
//return arr[1] // expected output person2
//return arr[2] // expected output person3
//return arr[3] // expected output Execution Error:Runtime Error: Out of Bounds.
HTH,
Egge-Jan
Each record contains a different number of items. some records contain a single item and another may contain 5. For example in the image below, the first record contains a single item and the second contains 6 items separated by semicolons. When I use the count function it only returns 1 item in the array because it seems to be looking at a record with only 1 item.
Thanks.