Is there a way to do a if in a do block


1) Give a description of the problem
Can i put a if in a do block
2) What is the expected behaviour?
When Run_counter1 = 1 i want to set firstr with date/time

3) What is happening/not happening?
can not get if where I would like it


it line 45 @run_counter1 =( @run_counter1+1)
the @runcounter1 did work and it was working it was add 1 every time the the script was run
but then i had the idea I like to known the first time the script has run but I am not sure how to do it


If is a statement but you ‘do’ tasks. You can put the do inside the if but not the other way around. What are you trying to accomplish?


hi @guxdude
what i am trying to do is the first time the script is run and run_counter1 = 1 i went to send the current date and time set to a variable called firstr


Global variables get set when the piston finishes execution, so @RunCounter will always lag behind by 1. (The second execution of the piston will have @RunCounter=1.)
One way around that issue is to set [email protected]+1 at the beginning of the piston and then set @RunCounter=runCounter at the end.
As you noted, the value of a variable when it’s not assigned a value is indeterminate. My experience is that numerics tend to be zero and strings tend to be a zero length string. One way to get around the indeterminateness is to assign a value using the edit option in the Variables section.


hi @qoheleth do you mean like this

where would i put the if to do the check for run count be 1 to set firstr ?


There may be an easier way to do it, but I haven’t found it yet.
If I absolutely have to set a value on a Global, I write a piston to do it.
For local number variables, there’s an edit icon in the Variables section that will allow you to edit the value.


You can also manually force data into a global variable without writing any code… Just go into edit mode on any piston… Then you will see that the global variables are clickable & editable.


do you mean like this


That’s it.