Doubts about syntaxes

Olá,

I some doubts about the syntax of some programming. There is an expression tag name zCountShift whose expression extracts the seconds from another time type tag and in the tag events scripts -> Value changed tag zCountShift there is a schedule like this:

SecondValue = currentValue.value
Execute = 0
	if SecondValue == 58: Execute = 1 #hour count
	if SecondValue == 57: Execute = 2 #spoilage count inout
	if initialChange == 1: Execute = 0

I can’t understand this part of the schedule. If anyone can explain to me a little I will be very grateful

# Copy current value of tag zCountShift into SecondValue variable.
SecondValue = currentValue.value
# Initialize Execute variable with zero value so it will be zero unless changed by following lines.
Execute = 0
# The next lines should not be indented like the code you posted, unless there was code cut out between them and the line above.
# If SecondValue is 58, set Execute to 1.
if SecondValue == 58: Execute = 1 #hour count
# If SecondValue is 57, set Execute to 2.
if SecondValue == 57: Execute = 2 #spoilage count inout
# If this is the initialChange for tag zCountShift, set Execute to 0.
if initialChange == 1: Execute = 0

Note = sets the variable before it to the value after it while == compares the values before and after it for equality (results in True if they’re equal, and False if not).

This looks like code to choose different functions to execute at 57 (hour count) and 58 (spoilage count) seconds. It likely does nothing the rest of the time when Execute is zero. The last line prevents this from executing due to initial value change when tag comes online after saving changes, etc.

1 Like

Expression tags must use only expression functions and the operators shown in the help sidebar. It is not jython. If you must, and you are careful not to block tag group execution, you can use the runScript() expression function to invoke jython.

1 Like

True; if I read right, @felipe2010silva shared part of the tag event script from zCountShift which would use Jython as above, though the indentation posted was wrong.

2 Likes

Huh, missed that part of the OP. Carry on. /:

2 Likes

@witman thank you for all help!!!

1 Like

@pturmel thank you for your help!!!