Select to view content in your preferred language

Lists in Arcade

6837
3
Jump to solution
07-17-2020 11:08 AM
JoeBorgione
MVP Emeritus

When constructing a list in a python script, it's easy to accommodate long entries to make them readable by splitting them into several lines:

myList = ['blahblah0', 'blahblah1', 'blahblah2',
          'blahblah3', 'blahblah4', 'blahblah5']‍‍

However, the same does not hold true in arcade.  I have to construct a list of attributes that goes on ad nauseam for an attribute rule .  Adding attribute field names in an arcade list that goes on seemingly forever is tedious at best.  Is there a way to manage a list such that arcade can be happy with it and I don't go blind?  Can I merge a series of lists together in arcade?  That way I could have multiple lists each of a readable size, and merge them into one 'one the fly' so arcade can read each of the attributes?

Xander Bakker

Chris Fox

That should just about do it....
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi Joe Borgione ,

In Arcade you can also split long lists over multiple lines:

var myList = ['blahblah0', 'blahblah1', 'blahblah2',
              'blahblah3', 'blahblah4', 'blahblah5'];

To combine multiple list you don't have the easy sum of the lists as you have in Python but you can do this:

var lst1 = ['blahblah0', 'blahblah1', 'blahblah2'];
var lst2 = ['blahblah3', 'blahblah4', 'blahblah5'];

var lst = lst1;
for (var i in lst2) {
    lst[Count(lst)] = lst2[i];
}

return lst;

...or even this (which will not work for lists with numeric data):

var lst1 = ['blahblah0', 'blahblah1', 'blahblah2'];
var lst2 = ['blahblah3', 'blahblah4', 'blahblah5'];
var lst  = Split(Concatenate(lst1, "#") + "#" + Concatenate(lst2, "#"), "#");
return lst;

View solution in original post

3 Replies
XanderBakker
Esri Esteemed Contributor

Hi Joe Borgione ,

In Arcade you can also split long lists over multiple lines:

var myList = ['blahblah0', 'blahblah1', 'blahblah2',
              'blahblah3', 'blahblah4', 'blahblah5'];

To combine multiple list you don't have the easy sum of the lists as you have in Python but you can do this:

var lst1 = ['blahblah0', 'blahblah1', 'blahblah2'];
var lst2 = ['blahblah3', 'blahblah4', 'blahblah5'];

var lst = lst1;
for (var i in lst2) {
    lst[Count(lst)] = lst2[i];
}

return lst;

...or even this (which will not work for lists with numeric data):

var lst1 = ['blahblah0', 'blahblah1', 'blahblah2'];
var lst2 = ['blahblah3', 'blahblah4', 'blahblah5'];
var lst  = Split(Concatenate(lst1, "#") + "#" + Concatenate(lst2, "#"), "#");
return lst;
JoeBorgione
MVP Emeritus

So all it takes is a semi colon and I'm good to go?  Awesome!  Thanks Xander Bakkerr!

That should just about do it....
XanderBakker
Esri Esteemed Contributor

Hi jborgion 

I don't think the semicolon is required. The "var " at the beginning is.