AnsweredAssumed Answered

Arcade expression for formatting a number into Station+ (Plus) format in WebMap Popup

Question asked by michael@denbury on Jul 16, 2018
Latest reply on Jul 16, 2018 by xander_bakker

Arcade expression for formatting a number into Station+ (Plus) format in WebMap Popup

 

I am trying to the equivalent Arcade expression for the following VBScript: 

Function FindLabel ( [Station] )
if (LEN(ROUND([Station],0))) = "7" then
FindLabel = LEFT(ROUND([Station],0),5) + "+" + RIGHT(ROUND([Station],0),2)
elseif (LEN(ROUND([Station],0))) = "6" then
FindLabel = LEFT(ROUND([Station],0),4) + "+" + RIGHT(ROUND([Station],0),2)
elseif (LEN(ROUND([Station],0))) = "5" then
FindLabel = LEFT(ROUND([Station],0),3) + "+" + RIGHT(ROUND([Station],0),2)
elseif (LEN(ROUND([Station],0))) = "4" then
FindLabel = LEFT(ROUND([Station],0),2) + "+" + RIGHT(ROUND([Station],0),2)
elseif (LEN(ROUND([Station],0))) = "3" then
FindLabel = LEFT(ROUND([Station],0),1) + "+" + RIGHT(ROUND([Station],0),2)
elseif (LEN(ROUND([Station],0))) = "2" then
FindLabel = LEFT(ROUND([Station],0),0) + "0+" + RIGHT(ROUND([Station],0),2)
elseif (LEN(ROUND([Station],0))) = "1" then
FindLabel = LEFT(ROUND([Station],0),0) + "0+0" + RIGHT(ROUND([Station],0),2)
else
FindLabel = ROUND([Station],0)
end if
End Function

 

It appears there is not an Arcade text/string LENGTH function to be able to return the number of characters.  Is there another way to format a number with varying digits/characters to take the last 2 digits for the record and insert a "+" before those 2 digits.

Example

VALUE      STATION

639249      6392+49

11715        117+15

234            2+34

Outcomes