Help with arcade language

372
4
05-19-2022 09:24 AM
Labels (1)
MarcosCampos
New Contributor

Hello guys,

i´m very new to arcade language so i trying to build a timer with a dinamic starting and ending time:

So i got this so far:

var dataini = Now();

var stat = "Closed";

if (stat == "Closed") {return dataini};

var datafim = 1;

 

So what i need is that my timer stops counting once my "stat" varaible is equal to "Closed".

I also need to grab that exact time an make it my "datafim" variable.

Hope you guys can help me... Thanks a lot in advance.

Greetings from Portugal

0 Kudos
4 Replies
JohannesLindner
MVP Frequent Contributor

Arcade is a relatively simple language. Things like POST requests, asynchronous processes and sleep() are not possible. What you describe doesn't seem possible in Arcade.

What is your end goal here? Maybe it can be achieved in another way (or not at all, but then you know...).


Have a great day!
Johannes
0 Kudos
MarcosCampos
New Contributor

Hello Johannes,

First of all thanks for your quick reply. According to my research this will be possible. The first thing that im having problems is that i have only one date/hour field and i have to use only that field to retrieve 2 variables. My starting date/time and my end date/time. In Python that would look similar this:

#dataocrr is my data/time field name
# stat is my field that i will use to a conditional formatting so to speek
#datafim is my end data/time field name

dataini = dataocrr - #simple right?

When stat == "Closed":
     return dataini as datafim

How can i do this in arcade!? Is it possible?

 

Have a nice day, and thanks again.

0 Kudos
JohannesLindner
MVP Frequent Contributor

Ah, I misunderstood your original question.

 

So you want to calculate a field "datafim" based on the fields "dataoccr" and "stat"? You can do that by using this expression in the CalculateField tool or in an Attribute Rule:

// Calulation Attribute Rule
// or Calculate Field
// on field "datafim"

var dataini = $feature.dataoccr  // read the dataoccr field of the current feature
if($feature.stat == "Closed") {  // if the value of field "stat" is "Closed"
    return dataini
}
return null  // $feature.stat != "Closed"

 


Have a great day!
Johannes
MarcosCampos
New Contributor

Hi again Johannes,

Thanks for the reply, i got that far myself, my problem was on to turn that returned value my other varaible ("datafim"). Can i do: " return dataini as var datafim"?

 

Thanks again, have a nice day. 

 

0 Kudos