Are Dynamic Constants flaky?

I have defined a Dynamic Constant and set it to global in the same way I have for many others in my code. For some reason if I try and do the following it doesnt replace the #lngAddNewClient with either the default text or the specific English text I have set:

lstActiveClients.AddRow “#lngAddNewClient

Why do you use quotes???

Not sure but I believe you lose the quotes…

and Dynamic Constant is such an oxymoron :smiley:

If you dont use the quotes and just use the #lngAddNewClient then you get a syntax error. I agree it is a very confusing concept to have a constant that changes, it feels a bit like politics!!

Or are you saying that if I just reference it without the # as a normal constant then behind the scenes it will dynamically alter?


Ok, that really needs to be documented because the only real info I could find on it was the blog post below and that is really confusing for a new user.

Thanks everyone for the help.

There is a difference between entering text in the Window and in code.

In code it is clear that if you enter text in quotes that it should be taken literally. Without quotes it is a constant or variable.

Me.text = “bummer” <- literal text
Me.text = kBummer <-text in the constant

How do you distinguish the two in the IDE interface builder? By marking the text with a # at the beginning.

Xojo User Guide 4 “Development” page 50. But I agree, it is not very clear.

I get that but what was not clear is that you dont use the # in code. without the quote so I was trying to use #DynamicVarName without quote and got a syntax error. Now that I know it is obvious but I think for new users it could me misleading. In fact I just re-watched Bob Keeneys video called “22.0 Localizing Your App Using Dynamic Constants” where he talks about this and at 10:34 he shows the dynamic constant used in code and correctly uses it without the # but I think what confused me was that he had a quoted string in the example beforehand and as he changed it quickly the " blurs and looks like the # has been entered. If you watch it slowly you can see that he has in fact not put in the # but just the variable name.

You could also watch the webinar “Localization”

I will do that thanks. Looking at page 47 of the manual it does say “Of course you can also refer to the dynamic constant in your
code just as you would any other constant.” so I guess it might just be me not understanding it correctly. Thanks for all the help.

I agree - It just doesn’t sound right.

Sorry that wasn’t clear.