# Getting the context in which a function is running?

**URL:** <https://forum.inductiveautomation.com/t/getting-the-context-in-which-a-function-is-running/33977>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [April 16, 2020, 12:28pm UTC](https://forum.inductiveautomation.com/t/getting-the-context-in-which-a-function-is-running/33977 "2020-04-16T12:28:40Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 16, 2020, 12:31pm UTC](https://forum.inductiveautomation.com/t/getting-the-context-in-which-a-function-is-running/33977/2 "2020-04-16T12:31:00Z")

</div>

> [@Best methods for checking script scope](http://forum.inductiveautomation.com/t/best-methods-for-checking-script-scope/30201/2):
>
> Try this: def getScope(): """ Returns: scope (int): 0=Gateway, 1=Client, 2=Designer """ try: if system.util.getSystemFlags() & system.util.CLIENT\_FLAG: location = 1 elif system.util.getSystemFlags() & system.util.DESIGNER\_FLAG: location = 2 except AttributeError: # system.util.getSystemFlags() does not exist in gateway scope location = 0 return location (Source: [Which scope is my code running in?](http://forum.inductiveautomation.com/t/which-scope-is-my-code-running-in/15540/3))

---

_[View the full topic](https://forum.inductiveautomation.com/t/getting-the-context-in-which-a-function-is-running/33977)._
