# Gotchas for Static Variable for a window's event?

**URL:** <https://forum.xojo.com/t/gotchas-for-static-variable-for-a-windows-event/59056>\
**Category:** Getting Started\
**Created:** [November 22, 2020, 3:38pm UTC](https://forum.xojo.com/t/gotchas-for-static-variable-for-a-windows-event/59056 "2020-11-22T15:38:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arthur\_Gabhart](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@Arthur\_Gabhart](https://forum.xojo.com/u/Arthur_Gabhart)\
**Post date:** [November 22, 2020, 3:38pm UTC](https://forum.xojo.com/t/gotchas-for-static-variable-for-a-windows-event/59056/1 "2020-11-22T15:38:37Z")

</div>

I’m having problems with my main window’s activate event recycling through some code.

I’m looking for gotchas for creating a static variable to stop it from going into a section of the event. This section is controlled by variables set outside of the event. The section is related to working on the app’s dictionary. What I would do is declare the variable at the head of event as true, and set it to false at the end of the event.

For instance I noticed a post [https://forum.xojo.com/t/static-in-a-window-method/13762](https://forum.xojo.com/t/static-in-a-window-method/13762) which to me implied even after the window closed, that the variable existed. I think it was misstated. Am I correct?

Are there other things to consider?

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [November 22, 2020, 4:55pm UTC](https://forum.xojo.com/t/gotchas-for-static-variable-for-a-windows-event/59056/2 "2020-11-22T16:55:42Z")

</div>

> [@Arthur\_Gabhart](#):
>
> which to me implied even after the window closed, that the variable existed. I think it was misstated. Am I correct?

No, Joe is. As a Xojo Engineer, Joe was very familiar with the framework. I tried to explain static variables here for you, but ended up with just different words for exactly what Joe said.

I’m not certain how to make it any more clear, so here’s the link to Static in the documentation

[https://documentation.xojo.com/api/language/static.html](https://documentation.xojo.com/api/language/static.html)

---

<div class="post-metadata">

**Author:** ![Arthur\_Gabhart](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@Arthur\_Gabhart](https://forum.xojo.com/u/Arthur_Gabhart)\
**Post date:** [November 22, 2020, 8:25pm UTC](https://forum.xojo.com/t/gotchas-for-static-variable-for-a-windows-event/59056/3 "2020-11-22T20:25:07Z")

</div>

Yeh. I want something that extinguishes with the window. The app as life is too long. Thanks for confirming the other way.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [November 22, 2020, 8:29pm UTC](https://forum.xojo.com/t/gotchas-for-static-variable-for-a-windows-event/59056/4 "2020-11-22T20:29:39Z")

</div>

A property on the window would do that.
