# Using constants

**URL:** <https://forum.xojo.com/t/using-constants/70940>\
**Category:** Getting Started\
**Created:** [June 28, 2022, 9:11pm UTC](https://forum.xojo.com/t/using-constants/70940 "2022-06-28T21:11:41Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![Steve\_Hill](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/7cd45c/32.png) [@Steve\_Hill](https://forum.xojo.com/u/Steve_Hill)\
**Post date:** [June 29, 2022, 10:38am UTC](https://forum.xojo.com/t/using-constants/70940/21 "2022-06-29T10:38:41Z")

</div>

OK that’s clear, thanks

---

<div class="post-metadata">

**Author:** ![Steve\_Hill](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/7cd45c/32.png) [@Steve\_Hill](https://forum.xojo.com/u/Steve_Hill)\
**Post date:** [July 1, 2022, 10:53am UTC](https://forum.xojo.com/t/using-constants/70940/22 "2022-07-01T10:53:40Z")

</div>

I still have a Constant headache. I did everything kevin g suggested and started small with cr and tab to be chr(13) and chr(9) but Xojo interpreted these as the literal characters chr(13) and chr(9) and all the strings I was constructing became gibberish.

Since I couldn’t see how to get the values I wanted accepted, I left the values blank and included cr = chr(13) and tab = chr(9) at the start of my winMain opening event, but that was not accepted since cr and tab were defined as constants and couldn’t be changed from being nothing to being something.

I wanted to do the right thing but have given up defeated and reverted to setting cr and tab and other constants as strings rather than waste any more time.

---

<div class="post-metadata">

**Author:** ![kevin\_g](https://forum.xojo.com/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kevin\_g](https://forum.xojo.com/u/kevin_g)\
**Post date:** [July 1, 2022, 11:11am UTC](https://forum.xojo.com/t/using-constants/70940/23 "2022-07-01T11:11:37Z")

</div>

You are trying to create constants that need to be calculated. Unfortunately, string constants defined in the navigator have to be literals and cannot involve any kind of calculation / function call.

The way I solve this limitation is to fake a constant using a property added to the module and then have a method in the module that initialises it.

This works as long as you don’t do anything stupid such as changing the value of the property elsewhere in your code.

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [July 1, 2022, 11:29am UTC](https://forum.xojo.com/t/using-constants/70940/24 "2022-07-01T11:29:07Z")

</div>

Again…

A constant that needs to be computed is a computed property  
Add a string variable CR  
Right click and convert to Computed Property

Then change the contents of the Get

 ![image](https://forum.xojo.com/uploads/default/original/2X/6/6242560c98ef40c374270e563c825087192f3468.png)

and comment out the Set

 ![image](https://forum.xojo.com/uploads/default/original/2X/4/4b434d85ab675b7539382c77e1b91a51c57730a3.png)

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [July 1, 2022, 11:41am UTC](https://forum.xojo.com/t/using-constants/70940/25 "2022-07-01T11:41:21Z")

</div>

> [@Steve\_Hill](#):
>
> I still have a Constant headache. I did everything kevin g suggested and started small with cr and tab to be chr(13) and chr(9) but Xojo interpreted these as the literal characters chr(13) and chr(9) and all the strings I was constructing became gibberish.

Beware of Xojo constants in a copy/paste, Xojo does not honor “inserted” constants as constants. LOL. I had a headache when I discovered that Xojo by itself changed all my chr(10) to chr(13) so I needed to fix my constant later replacing those chr(13) by chr(10) again in a variable before using it.

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [July 1, 2022, 11:41am UTC](https://forum.xojo.com/t/using-constants/70940/26 "2022-07-01T11:41:23Z")

</div>

Why do you want to define constants that are already there? Check out EndOfLine.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [July 1, 2022, 12:18pm UTC](https://forum.xojo.com/t/using-constants/70940/27 "2022-07-01T12:18:14Z")

</div>

He talked about cr and tab; he probably does not saw EndOf Line, but the question is still valid (for Tab).

[Previous page](https://forum.xojo.com/t/using-constants/70940.md?page=1)
