# How to run script continuously in perspective?

**URL:** <https://forum.inductiveautomation.com/t/how-to-run-script-continuously-in-perspective/87389>\
**Category:** Ignition\
**Tags:** python, ignition81, perspective, scripting\
**Created:** [March 15, 2024, 9:10am UTC](https://forum.inductiveautomation.com/t/how-to-run-script-continuously-in-perspective/87389 "2024-03-15T09:10:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sachin\_Jagtap](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@Sachin\_Jagtap](https://forum.inductiveautomation.com/u/Sachin_Jagtap)\
**Post date:** [March 15, 2024, 9:10am UTC](https://forum.inductiveautomation.com/t/how-to-run-script-continuously-in-perspective/87389/1 "2024-03-15T09:10:37Z")

</div>

I have created a function and I want to run it continuously. Where should i call or write this function.

---

<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:** [March 15, 2024, 9:12am UTC](https://forum.inductiveautomation.com/t/how-to-run-script-continuously-in-perspective/87389/2 "2024-03-15T09:12:11Z")

</div>

Scripts should never be run continuously. They should be event driven.

What are you trying to do?

---

<div class="post-metadata">

**Author:** ![kpmalik](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@kpmalik](https://forum.inductiveautomation.com/u/kpmalik)\
**Post date:** [March 15, 2024, 10:03am UTC](https://forum.inductiveautomation.com/t/how-to-run-script-continuously-in-perspective/87389/3 "2024-03-15T10:03:23Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/b/db3bd67d3176bcade02a214cac677bd9521475b0.png)  
Beginner/Learner here, I had a similar need and did this temporary work around.  
Inserted a table \> created a named query with polling rate 1 sec to keep the query running continuously. Once it satisfied my requirement, I re-sized it to a very small square shape and changed visibility to false in properties. Not the best practice but hope it answers your question.

---

<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:** [March 15, 2024, 10:15am UTC](https://forum.inductiveautomation.com/t/how-to-run-script-continuously-in-perspective/87389/4 "2024-03-15T10:15:13Z")

</div>

That's probably what the OP needs.

A couple of points:

> [@Khurram\_Malik](#):
>
> to keep the query running continuously.

That named query isn't running continuously. It's running periodically. It does its job and terminates each time. That's the right way.

> [@Khurram\_Malik](#):
>
> I re-sized it to a very small square shape and changed visibility to false in properties.

I don't understand this. Only components are visible. A name query isn't a component. It sounds like you created a component to hold the value of the named query but instead you should have created a custom property on the view and make the query binding on that.

---

<div class="post-metadata">

**Author:** ![kpmalik](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@kpmalik](https://forum.inductiveautomation.com/u/kpmalik)\
**Post date:** [March 15, 2024, 10:24am UTC](https://forum.inductiveautomation.com/t/how-to-run-script-continuously-in-perspective/87389/5 "2024-03-15T10:24:47Z")

</div>

copy that, I am not there yet (custom property), but will take note and try it.. Thank you for taking the time to share your expertise..

---

<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:** [March 15, 2024, 10:52am UTC](https://forum.inductiveautomation.com/t/how-to-run-script-continuously-in-perspective/87389/6 "2024-03-15T10:52:23Z")

</div>

The custom properties are a very handy way of making variables available to all the components on your view. If you don't use them and you try to bind one component to another you wind up with a bunch of getSibling and getChild references which break if you rename components or move them into another container as the relative path has now changed.

If you use custom properties on the view you can bind your components to those instead. So, let's say you have a DateTime component selecting a date which will be used by something else:

- Create a custom property "startDate"
- Bind the DateTime's value property to that and make it bidirectional so that the DateTime can update the custom prop.
- Now, anything that would have previously referenced the DateTime value should bind to `view.custom.starDate` instead.
