#CONSTANT_NAME Not Working In Xojo 2013R3

I have a large application with several thousand constants that have been used to internationalize the app. For many years I’ve been able to put #CONSTANT_NAME as the .text value for things like labels, and the default value for that constant would appear in the IDE. Today using Xojo 2013 R3 I discover that this appears to no longer work.

When I first load up a project, the constants appear in the windows as you would expect, as in this first screenshot.

As soon as I click on the content of ANY window, then ALL the constant values are removed from ALL windows, as in this second screenshot.

If I edit the value of the text for the label, and add a space to the end of the constant name, then the #CONSTANT_NAME shows up in the ide window. If I then remove the space, the correct default value for that label only shows back up.

I have more than 30 windows in this app, with thousands of places I’ve set up labels and other UI using constants in this fashion. PLEASE don’t tell me I have to reset EVERY one of them like this. :frowning:

Can you share a small sample?

I see you’re on the beta list - did you happen to open it in the beta ?
The other thing I can’t fathom is WE use this in the IDE all over.

I did not open this particular project in the beta. I’m working on producing a smaller project that demonstrates this issue.

Interesting… My project is composed of lots of external items, as I re-use some components in other projects, and only wanted to write them once and keep them in sync. The windows I was testing this with are all stored externally to the project.

When I created a smaller project using one of my external windows and my external Strings module that is filled with thousands of string constants, I was able to duplicate the problem. One window, and my strings module.

But they were both still external.

So I pulled them internal so I could package up the sample to share in Feedback, but then discovered when opening the now-no-external-items project that many of my controls were using deprecated supers:

I selected all, and had the IDE fix them all for me (changing them all to use Label as their super). Now the problem has disappeared.

So, this begs another question: Why didn’t the IDE warn me about deprecated supers when the window was stored as an external project item? Is this a known issue?

I raised a (possibly related) issue with StaticTexts earlier in the beta cycle: https://forum.xojo.com/4575-beta-6-vcp-format-changes-with-statictext

[quote=34329:@Kimball Larsen]Interesting… My project is composed of lots of external items, as I re-use some components in other projects, and only wanted to write them once and keep them in sync. The windows I was testing this with are all stored externally to the project.
[/quote]
Interesting indeed. Your External items: are these stored as Binary or XML format?

A mixture, but mostly XML or VCP.

I have an old project with similar issues: lots of StaticTexts. For fun today, I tried loading it and using the IDE’s “resolve” feature in 2013 R3 to convert these to Labels.

The result was not pretty: it seems to have destroyed most of the captions in my static texts.

I’m going through mine one at a time. 437 left… Wheee!

What I’m seeing is that StaticTexts with Captions were converted to Labels properly. They show up fine in the IDE, and when I save the file (as XML/VCP) I can see the .Text value is saved in the project. However, at runtime, they show up as blank. This seems to be unrelated to the use of constants - just a regular “hello world” staticText is showing up blank at runtime when it’s been converted to a Label.

Ugh. That does not bode well for me. I’ll finish converting all my old StaticTexts and let you know what I see at runtime.

Fortunately, my code is all under SVN so I can back-out any changes. Regression testing using prior versions: (Test procedure : undo changes using SVN revert. Open the project file, use the IDE’s “Resolve Issue” feature to convert StaticTexts to Labels, and then hit Run to see if they show up) gives these results:

2013 R3 : Broken: Captions show in the IDE but are Empty at runtime.
2013 R2 : Works fine

So this really seems like a new bug in 2013 R3, which is unfortunate.

The good news - after using 2013 R2 to do the the StaticText->Label “resolve issue” conversion, I saved the file, and opened in 2013 R3, and most of them seem to be fine. So there is a workaround. (Some of my captions don’t look right, but these ones seem to be in Label subclasses - need to investigate this more).

Whether this fixes your original issue (with #CONSTANTs) I don’t know. May be 2 or 3 different bugs?

You might want to step back to 12r2.1, convert the deprecated controls and then try 13r3 again. I converted all of my old code in 12r2.1 and I’m not seeing the issues in 13r3 - and my dynamic constants have 5 and sometimes 6 languages attached.

Ok, I’m definitely seeing something weird with Label subclasses, too. They are blank at runtime even though they appear fine in the IDE. Regular staticTexts converted to Labels (using 2013 R2, then imported into 2013 R3) are fine, though. Weird. I’ll do more testing on this issue.

Try this:

  • new project
  • add new Class cLabel which is a Label subclass
  • add a Label (Label1) to your Window, change it to cLabel, and set the Text caption. Run - it works fine.
  • change superclass of Label1 from cLabel to StaticText. Run - it works fine.
  • Save project, reopen
    Result: Label1 appears blank in the IDE, even though the “Text” property does show the caption you entered.

So, 2013 R3 seems to have some general issue with changing the superclass of a Label to/from a StaticText and saving/loading this properly.

Peeking at the VCP format files : it seems that the issue is that sometimes these converted Labels have both a “Text” property and a “Caption” property - the Text property is non-blank, but the Caption is blank (or vice-versa).

It seems that there are two possible failure modes here:

  • the text caption shows up in the IDE but is blank at runtime
  • the text caption is blank in the IDE but visible at runtime.

FY I, I tried going back to 2012 R2 and doing the conversion - I’m still seeing the same problem : regular StaticTexts convert OK, but Label Subclasses lose their caption at runtime in 2013 R3.

Fortunately I don’t have a ton of those, but I’m also not exactly how to fix them once they get corrupted.

I’m able to confirm that regular StaticTexts simply converted to Labels seem to work correctly in 13R3. I don’t have any subclassed labels, but it seems your trivial example exposes a reproducible bug.

Once your project gets in this state with Label subclasses that don’t show properly, it can be fixed manually:

  • open the VCP-format file
  • in the offending control, find the line that says
Text="mycaption"
  • delete the string between the quotes, and move it to the line that says
Caption=""

E.g., swap the values of “Text” and “Caption”.

I’ve tested this and it does appear to survive an edit/save/reload cycle in the 2013 R3 IDE.