<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to slice array in Arcade? in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/491919#M24822</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, thanks again! Will make do until fall, I guess.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Jul 2019 19:11:47 GMT</pubDate>
    <dc:creator>Zeke</dc:creator>
    <dc:date>2019-07-09T19:11:47Z</dc:date>
    <item>
      <title>How to slice array in Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/491914#M24817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an Arcade expression that I want to use for labeling. If the label field (named Label) is two words or less, I return the field. This works fine. But if the Label is more than two words, it should return the first two words, followed by a newline, then the rest of the words. In Python, this would be something like &lt;SPAN style="color: #0000ff;"&gt;lbl_array[:2] + '\n' + lbl_array[2:]&lt;/SPAN&gt;. But I can't figure out or find how to slice Arcade array elements like that. I could use a for loop to construct the label, but there should be a way to use the indexes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;var lbl = $feature["Label"]&lt;/P&gt;&lt;P&gt;var lbl_array = Split(lbl, ' ')&lt;/P&gt;&lt;P&gt;if (count(lbl_array) &amp;lt; 3) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return lbl }&lt;/P&gt;&lt;P&gt;else {&lt;/P&gt;&lt;P&gt;?? }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2019 12:22:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/491914#M24817</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2019-07-09T12:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to slice array in Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/491915#M24818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/9431" target="_blank"&gt;Greg Keith&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the code below, but since you mention that you are creating labels, you will not&amp;nbsp;be able to use the NewLine constant. This will be supported when the new web map based on JavaScript API 4.x becomes available this fall:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; txt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"aaaa bb ccc d"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; arr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Split&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;txt&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;" "&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Count&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; arr_new &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;arr&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; arr&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Concatenate&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arr_new&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; TextFormatting&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;NewLine&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;//var result = arr[0] + TextFormatting.NewLine + arr[1];&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; txt&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; result&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:38:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/491915#M24818</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T21:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to slice array in Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/491916#M24819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, thanks. Found this on the &lt;A _jive_internal="true" href="https://community.esri.com/ideas/15261-support-multi-line-labels-using-arcade-in-agol"&gt;Ideas page&lt;/A&gt;, upvoted it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2019 14:17:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/491916#M24819</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2019-07-09T14:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to slice array in Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/491917#M24820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing though. Is it possible to use index slicing, like in Python, or do array elements need to be accessed individually? If the latter, it seems like a big drop in usefullness compared to using Python.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2019 17:52:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/491917#M24820</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2019-07-09T17:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to slice array in Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/491918#M24821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/9431"&gt;Greg Keith&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Slicing (slice) is not a supported function in Arcade (yet?). When you compare Python with Arcade, Python has a lot more functionality and module you can plug in. However, Arcade has a different purpose. It is meant as a cross-platform language that can be used for things that are not possible to do with Python (like configuring a pop-up and cross referencing other data layer and dynamically do analysis to show the results in that pop-up). A lot of functionality is being developed and more profiles (places where you can apply Arcade) are being added. Although there is still a lot of work ahead for enhancements, Arcade is pretty cool as it is right now...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will probably run into&amp;nbsp;several limitations of Arcade like the NewLine that is not supported, but that specific case is not a limitation of Arcade. It is a limitation of the web map based on the JavaScript API 3.x. Later this year the web map will receive an upgrade to 4.x and that will remove that limitation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2019 18:53:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/491918#M24821</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2019-07-09T18:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to slice array in Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/491919#M24822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, thanks again! Will make do until fall, I guess.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2019 19:11:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/491919#M24822</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2019-07-09T19:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to slice array in Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/1127145#M43442</link>
      <description>&lt;P&gt;Arcade now has a &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#slice" target="_blank" rel="noopener"&gt;Slice function&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 14:39:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/how-to-slice-array-in-arcade/m-p/1127145#M43442</guid>
      <dc:creator>KevinMayall</dc:creator>
      <dc:date>2021-12-17T14:39:28Z</dc:date>
    </item>
  </channel>
</rss>

