Script not entering my FOR loop

This script is being handled by a tag change event on my gateway, and the script is not entering my for loop, which loops through each row in a query response.

As you can see below, there are no entries to the log from inside the FOR loop, even though all of it’s preceding parameters have been met.

Are you sure that breaks as has data in it? What happens if you right before the for loop.

1 Like

I do get an entry in my gateway log if I “” on the line before the loop.

This script works fine if I run it manually from my script console too, which I think is strange. Breaks does have data in it.

Before the for loop…
Log the length of breaks:

Also show this one

share results

1 Like

Oh yeah, my query is not returning any rows…

if I run the same query in my script console, I get 4 rows back.


What is your pausedArea value in your script console? I think that must be your culprit. You have it correct in your script console but your str(event.tagPath)[1:4] is not correct in your tag event I would guess. Log pausedArea see if it matches what you’re feeding as pausedArea in your script console.

@Mitchell - a tip:
Post code rather than images and use the </> formatting button to preserve formatting and indents. That we can can copy and paste it into our answers rather than have to copy it from an image and type it out again.

Welcome to the forum.

1 Like

Yeah, you’re right. str(event.getTagPath)[1:4] returns “bou”, and I need it to return “A05”.

Thank you @bkarabinchak.psi ! I really appreciate the help!

1 Like

@Transistor I will certainly remember that for next time!
@jespinmartin1 thank you for your help as well!

In case anyone else stumbles upon this thread in the future
event.getTagPath() did not return the raw tag path as a string like I thought it did, so the line pausedArea = str(event.getTagPath)[1:4] was not returning what I needed it to.

I changed pausedArea = str(event.getTagPath)[1:4] to pausedArea = str(event.getTagPath().getParentPath())[1:4], as the event.getTagPath().getParentPath() returns the raw tag path for the tag that changed.

No, your real problem was missing parentheses. You were converting the method object to a string, not the result of the method. "bou" was part of the word "bound", for a bound method.

1 Like

ohhh okay I get it. I thought it seemed odd that str(event.getTagPath) returned what it did.

Jython automatically turns Java methods like getX and setX into properties (.x), if they properly conform to the JavaBean “specification”. So asking for x.tagPath is calling getTagPath() for you, basically.

1 Like