# Declaring publicly accessible variables in code

**URL:** <https://forum.xojo.com/t/declaring-publicly-accessible-variables-in-code/12267>\
**Category:** General\
**Created:** [November 12, 2013, 9:22pm UTC](https://forum.xojo.com/t/declaring-publicly-accessible-variables-in-code/12267 "2013-11-12T21:22:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oliver\_Scott-Brown](https://forum.xojo.com/letter_avatar_proxy/v4/letter/o/8baadc/32.png) [@Oliver\_Scott-Brown](https://forum.xojo.com/u/Oliver_Scott-Brown)\
**Post date:** [November 12, 2013, 9:22pm UTC](https://forum.xojo.com/t/declaring-publicly-accessible-variables-in-code/12267/1 "2013-11-12T21:22:05Z")

</div>

How do you declare variables I code as if you where adding them as a ‘Property’. This is just how I want to organise my properties, using code that is. Is this possible? Also how do I group properties if I was to add them for them as a ‘Property’? If I knew of this functionality I wouldn’t even be asking this question.

Thanks

---

<div class="post-metadata">

**Author:** ![Eric\_Williams](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/ecccb3/32.png) [@Eric\_Williams](https://forum.xojo.com/u/Eric_Williams)\
**Post date:** [November 12, 2013, 9:30pm UTC](https://forum.xojo.com/t/declaring-publicly-accessible-variables-in-code/12267/2 "2013-11-12T21:30:47Z")

</div>

No. Properties are only defined at the user interface level. Also, you cannot group Properties.

---

<div class="post-metadata">

**Author:** ![Peter\_Truskier](https://forum.xojo.com/user_avatar/forum.xojo.com/peter_truskier/32/243_2.png) [@Peter\_Truskier](https://forum.xojo.com/u/Peter_Truskier)\
**Post date:** [November 12, 2013, 9:46pm UTC](https://forum.xojo.com/t/declaring-publicly-accessible-variables-in-code/12267/3 "2013-11-12T21:46:05Z")

</div>

One way that you could kinda do this is to create a globally accessible dictionary for each “group” with the names of your properties (as strings) being the keys, and the values being variants.

The problem with this approach is that you would lose all type safety and compiler checking that you would have with normally-defined properties. It could lead to a bunch of annoying problems that would be caught at runtime, not when compiling.

All in all, I would suggest trying to get used to the way that virtually everybody works in a strongly-typed language…

---

<div class="post-metadata">

**Author:** ![shao\_sean](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/ed8c4c/32.png) [@shao\_sean](https://forum.xojo.com/u/shao_sean)\
**Post date:** [November 13, 2013, 7:17am UTC](https://forum.xojo.com/t/declaring-publicly-accessible-variables-in-code/12267/4 "2013-11-13T07:17:53Z")

</div>

You could always create modules and store the properties in there… Create a module for each “group” and then when you add the properties to the module, set the scope to “Protected” that way you will need to type in the full path to the property (and this allows you to have the same property name in different groups)…

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 4:56pm UTC](https://forum.xojo.com/t/declaring-publicly-accessible-variables-in-code/12267/5 "2020-10-29T16:56:06Z")

</div>


