Non-zero constant is zero at run time

  1. 2 weeks ago

    Rob H

    Sep 4 Canada

    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:

    -image-

    it's called by this method, CalculateLandedCost:

    -image-

    Test Project

  2. Rob H

    Sep 4 Canada

    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?

  3. Norman P

    Sep 4 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    I really doubt that

    Here your sample shows kOzToGrams = 28.35

  4. Rob H

    Sep 4 Canada

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

  5. Norman P

    Sep 4 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    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

  6. Rob H

    Sep 4 Canada

    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?

  7. Norman P

    Sep 4 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    it might

  8. 3 days ago

    Rob H

    Sep 16 Canada

    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..

  9. Kem T

    Sep 16 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut

    Or you need to clear your cache.

  10. Rob H

    Sep 16 Canada

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

  11. Kem T

    Sep 16 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut

    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.

  12. Emile S

    Sep 16 Europe (France, Strasbourg)

    @Rob H 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..

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

or Sign Up to reply!