<?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 How to simplify multiline expression into 1 expression in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/how-to-simplify-multiline-expression-into-1/m-p/1583814#M7423</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've been trying to create a way&amp;nbsp; to return the slope of a line by using the elevation values obtained via the intersection of the start and end vertex of the line with topo contours.&amp;nbsp; Creating separate scripts&amp;nbsp; for attribute fields of the line (i.e., start elv, end elv, length) and then using those values in an equation field worked, but it takes a very long time to process.&amp;nbsp; I thought a viable alternative is to configure a popup with the same scripts condensed into one arcade expression.&amp;nbsp; I tried to configure the pop up with multi line script but it only returns the start vertex elevation value.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice is much appreciated.&lt;/P&gt;&lt;P&gt;The script is below:&lt;/P&gt;&lt;P&gt;//Start vertex (upper elevation) of line used for slope&lt;BR /&gt;var paths = Geometry($feature).paths&lt;BR /&gt;var line = paths[0][0]&lt;/P&gt;&lt;P&gt;//Selecting the elevation of the contour that is intersected by the start vertex&lt;BR /&gt;var x = featuresetbyname($datastore,"Homer_2ft_contour_Lidar_Gen")&lt;BR /&gt;for(var f in x){&lt;BR /&gt;if(intersects(line,f)){&lt;BR /&gt;return f.Contour}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//End vertex of line used for slope&lt;BR /&gt;Var p = paths[0][1]&lt;/P&gt;&lt;P&gt;//End vertex (lower elevation) of line used for slope&lt;BR /&gt;var y = featuresetbyname($datastore,"Homer_2ft_contour_Lidar_Gen")&lt;BR /&gt;for(var g in y){&lt;BR /&gt;if(intersects(p,g)){&lt;BR /&gt;return g.Contour}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//Equation to return slope of line&lt;BR /&gt;var z = (f-g)/$feature.Shape_Length * 100&lt;BR /&gt;return z&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;A. Yeaton&lt;/P&gt;</description>
    <pubDate>Mon, 10 Feb 2025 22:28:51 GMT</pubDate>
    <dc:creator>Yeaton</dc:creator>
    <dc:date>2025-02-10T22:28:51Z</dc:date>
    <item>
      <title>How to simplify multiline expression into 1 expression</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-simplify-multiline-expression-into-1/m-p/1583814#M7423</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've been trying to create a way&amp;nbsp; to return the slope of a line by using the elevation values obtained via the intersection of the start and end vertex of the line with topo contours.&amp;nbsp; Creating separate scripts&amp;nbsp; for attribute fields of the line (i.e., start elv, end elv, length) and then using those values in an equation field worked, but it takes a very long time to process.&amp;nbsp; I thought a viable alternative is to configure a popup with the same scripts condensed into one arcade expression.&amp;nbsp; I tried to configure the pop up with multi line script but it only returns the start vertex elevation value.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice is much appreciated.&lt;/P&gt;&lt;P&gt;The script is below:&lt;/P&gt;&lt;P&gt;//Start vertex (upper elevation) of line used for slope&lt;BR /&gt;var paths = Geometry($feature).paths&lt;BR /&gt;var line = paths[0][0]&lt;/P&gt;&lt;P&gt;//Selecting the elevation of the contour that is intersected by the start vertex&lt;BR /&gt;var x = featuresetbyname($datastore,"Homer_2ft_contour_Lidar_Gen")&lt;BR /&gt;for(var f in x){&lt;BR /&gt;if(intersects(line,f)){&lt;BR /&gt;return f.Contour}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//End vertex of line used for slope&lt;BR /&gt;Var p = paths[0][1]&lt;/P&gt;&lt;P&gt;//End vertex (lower elevation) of line used for slope&lt;BR /&gt;var y = featuresetbyname($datastore,"Homer_2ft_contour_Lidar_Gen")&lt;BR /&gt;for(var g in y){&lt;BR /&gt;if(intersects(p,g)){&lt;BR /&gt;return g.Contour}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;//Equation to return slope of line&lt;BR /&gt;var z = (f-g)/$feature.Shape_Length * 100&lt;BR /&gt;return z&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;A. Yeaton&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 22:28:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-simplify-multiline-expression-into-1/m-p/1583814#M7423</guid>
      <dc:creator>Yeaton</dc:creator>
      <dc:date>2025-02-10T22:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to simplify multiline expression into 1 expression</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-simplify-multiline-expression-into-1/m-p/1584081#M7424</link>
      <description>&lt;P&gt;It's giving you only the beginning vertex since you have a return function when you get an intersecting contour. You want to save that value and use it later. This shows two different outputs to select from, only the slope or the start elevation, the end elevation, and the slope. It also included breaks so you don't have to loop through all the contours.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//Start vertex (upper elevation) of line used for slope
var paths = Geometry($feature).paths;
var line = paths[0][0];
var begin = 0;
var end = 0;
//Selecting the elevation of the contour that is intersected by the start vertex
var x = featuresetbyname($datastore, "Homer_2ft_contour_Lidar_Gen");
for (var f in x) {
  if (intersects(line, f)) {
    begin = f.Contour;
    break;
  }
}

//End vertex of line used for slope
var p = paths[0][1];

//End vertex (lower elevation) of line used for slope
var y = featuresetbyname($datastore, "Homer_2ft_contour_Lidar_Gen");
for (var g in y) {
  if (intersects(p, g)) {
    end = g.Contour;
    break;
  }
}

//Equation to return slope of line
return (begin - end) / $feature.Shape_Length * 100;

//or if you want all values, you can use this return
return `Start elevation: ${begin}
End elevation: ${end}
Slope: ${(begin - end) / $feature.Shape_Length * 100}`;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2025 16:35:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-simplify-multiline-expression-into-1/m-p/1584081#M7424</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-02-11T16:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to simplify multiline expression into 1 expression</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-simplify-multiline-expression-into-1/m-p/1584153#M7425</link>
      <description>&lt;P&gt;Thanks for the prompt reply, Ken!&amp;nbsp; I will give this a try and let you know how it goes.&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Aaron&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2025 18:18:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-simplify-multiline-expression-into-1/m-p/1584153#M7425</guid>
      <dc:creator>Yeaton</dc:creator>
      <dc:date>2025-02-11T18:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to simplify multiline expression into 1 expression</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-simplify-multiline-expression-into-1/m-p/1584708#M7426</link>
      <description>&lt;P&gt;Thanks Ken,&amp;nbsp; your script worked nicely.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Aaron&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 23:17:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-simplify-multiline-expression-into-1/m-p/1584708#M7426</guid>
      <dc:creator>Yeaton</dc:creator>
      <dc:date>2025-02-12T23:17:17Z</dc:date>
    </item>
  </channel>
</rss>

