Non-zero constant is zero at run time

I have a class constant that I have set with a numeric value in the IDE at run time. I have a shared method in the class that uses the constant and at run time the value is zero. In the IDE it has a numeric value of 28.35.

I didn’t think that was possible, given that it’s a constant.

The code is part of a larger project that would be problematic for me to post, but I replicated my workflow in a test project that I have attached. The thing is, it works as I expected in this project.

It doesn’t in my real project. Did I mess this up somehow?

This is a screenshot of my actual code so you can see what I’m doing:

This is my UnitConversion class, with my shared (static) method:

it’s called by this method, CalculateLandedCost:

Test Project

ok so I sort of figured it out.

I changed kOzToGram to OuncesToGrams and it worked perfectly. I searched the project for kOzToGram and there were no other definitions for that.

Did I violate some kind of naming rule?

I really doubt that

Here your sample shows kOzToGrams = 28.35

I know. I changed my code after I posted this. I don’t understand either.

without seeing the original its hard to know what you were experiencing

can say I’ve never seen such an issue

and the only naming rule you might violate is that you cant name the constant the same as a keyword - but the IDE would stop you from doing that when you try to create the constant

Yeah, that’s what I would have thought as well.

I realize it’s hard to help without the actual code. I have licenses for a few 3rd party add ons I bought and the project will break without them.

I’ll post a video when I get home later of what’s happening and it will show the values in the debugger at run time. Maybe that will help?

it might

Just to close this off… I made some kind of mistake. I’m not sure what it was but the code I posted worked as I expected I returned home later in the day. I don’t have an explanation for this, other than I made a mistake someplace. I’ve I knew what the code was that I broke, I would’ve posted it so we’d know…

Or you need to clear your cache.

I wondered that too. I don’t know much about the XoJo cache. I’m assuming it’s self managing for the most part?

Yes, but every now and then…

Look in the preferences for the relevant button, and even though it’s not required, I like to restart Xojo after.

I get this one so many times… I was starting to believe that I was cursed :frowning: