# Script not entering my FOR loop

**URL:** <https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272>\
**Category:** Ignition\
**Created:** [February 17, 2022, 5:42pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272 "2022-02-17T17:42:50Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mitchell\_Felix](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mitchell\_Felix](https://forum.inductiveautomation.com/u/Mitchell_Felix)\
**Post date:** [February 17, 2022, 5:42pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/1 "2022-02-17T17:42:50Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/6/e6ebb0d1c2355915813a7757569a1ad1ce20f85c.png)  
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.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/2/a2c603f5d46e54b62c29503e5e5decf1f3fc70d9.png)

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 17, 2022, 5:45pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/2 "2022-02-17T17:45:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mitchell\_Felix](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mitchell\_Felix](https://forum.inductiveautomation.com/u/Mitchell_Felix)\
**Post date:** [February 17, 2022, 5:53pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/3 "2022-02-17T17:53:43Z")

</div>

I do get an entry in my gateway log if I “logger.info(breaks)” 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.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [February 17, 2022, 6:03pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/4 "2022-02-17T18:03:01Z")

</div>

Before the for loop…  
Log the length of `breaks`:

```auto
logger.info(str(breaks.getRowCount()))

```

Also show this one

```auto
logger.info(str(breaks.getColumnNames()))

```

share results

---

<div class="post-metadata">

**Author:** ![Mitchell\_Felix](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mitchell\_Felix](https://forum.inductiveautomation.com/u/Mitchell_Felix)\
**Post date:** [February 17, 2022, 6:06pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/5 "2022-02-17T18:06:45Z")

</div>

Oh yeah, my query is not returning any rows…

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/f/3fa6c23ba07f43d4881bd33866146c87dca521a9.png)

---

<div class="post-metadata">

**Author:** ![Mitchell\_Felix](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mitchell\_Felix](https://forum.inductiveautomation.com/u/Mitchell_Felix)\
**Post date:** [February 17, 2022, 6:10pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/6 "2022-02-17T18:10:42Z")

</div>

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

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/9/79528a5f5c82bc386cc2c971c79da1a7fc29839b.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/b/9b60d3e55c5588ea56b9c80aa36d4faa95d06741.png)

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 17, 2022, 6:14pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/7 "2022-02-17T18:14:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 17, 2022, 6:18pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/8 "2022-02-17T18:18:19Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Mitchell\_Felix](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mitchell\_Felix](https://forum.inductiveautomation.com/u/Mitchell_Felix)\
**Post date:** [February 17, 2022, 6:23pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/9 "2022-02-17T18:23:28Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Mitchell\_Felix](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mitchell\_Felix](https://forum.inductiveautomation.com/u/Mitchell_Felix)\
**Post date:** [February 17, 2022, 6:24pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/10 "2022-02-17T18:24:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mitchell\_Felix](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mitchell\_Felix](https://forum.inductiveautomation.com/u/Mitchell_Felix)\
**Post date:** [February 17, 2022, 6:39pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/11 "2022-02-17T18:39:06Z")

</div>

**In case anyone else stumbles upon this thread in the future**  
ROOT ISSUE:  
`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.

SOLUTION:  
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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 17, 2022, 6:42pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/12 "2022-02-17T18:42:16Z")

</div>

> [@Mitchell\_Felix](#):
>
> str(event.getTagPath)

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.

---

<div class="post-metadata">

**Author:** ![Mitchell\_Felix](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mitchell\_Felix](https://forum.inductiveautomation.com/u/Mitchell_Felix)\
**Post date:** [February 17, 2022, 6:55pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/13 "2022-02-17T18:55:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 17, 2022, 6:58pm UTC](https://forum.inductiveautomation.com/t/script-not-entering-my-for-loop/56272/14 "2022-02-17T18:58:53Z")

</div>

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.
