{"id":799,"date":"2020-07-13T19:13:00","date_gmt":"2020-07-14T01:13:00","guid":{"rendered":"https:\/\/www.great-white-software.com\/blog\/?p=799"},"modified":"2020-07-08T19:40:53","modified_gmt":"2020-07-09T01:40:53","slug":"dynamic-const-or-not","status":"publish","type":"post","link":"https:\/\/www.great-white-software.com\/blog\/2020\/07\/13\/dynamic-const-or-not\/","title":{"rendered":"Dynamic const or not ?"},"content":{"rendered":"\n<p>In the IDE you can create constants. <\/p>\n\n\n\n<p>And if you create them as string constants you can set them to be &#8220;localized&#8221; or not.<\/p>\n\n\n\n<p>This gives you the ability to support multiple different languages in a single build as the localized language files will be saved and used by your application.<\/p>\n\n\n\n<p>But what happens to other kinds of constants if you add different instance values to ? What does the IDE do with those ? And how does it use those ?<\/p>\n\n\n\n<p>Create a new desktop project. Add a new number constant, kWindowMin. Then add set a new instance value for MacOS ANY LANGUAGE and make the value 500. Add another instance for Windows ANY LANGUAGE and make the value 700.<\/p>\n\n\n\n<p>Set the Window1 Width to #kWindowMin<\/p>\n\n\n\n<p>And notice what it does on macOS (or Windows) immediately. Then run it on macOS and Windows.<\/p>\n\n\n\n<p>Note that this is NOT a value looked up at runtime. It&#8217;s not determined at runtime like a dynamic language constant is. With a dynamic constant you can change the system language, run and if there is a localization for that language it will show that localization. Stop the app, switch languages and run again and the new language should show.<\/p>\n\n\n\n<p>This kind of constant is looked up in a platform specific way at COMPILE \/ BUILD time.<\/p>\n\n\n\n<p>Its set AT COMPILE TIME and never again.<\/p>\n\n\n\n<p>They can be handy because in some situations you need a larger window or field size because the default localized values for a language are longer (German tends to be this way compared to English)<\/p>\n\n\n\n<p>And since you can use it for all kinds of values including integers yiu could use it for colors and have a different set of colors you use for macOS or Windows quite easily.<\/p>\n\n\n\n<p>And you can use Booleans. So with settings for transparency its fairly easy to set up one value for macOS to be TRUE &#8211; since it supports transparency very nicely &#8211; and FALSE for Windows. Then you can assign that constant to those Windows &amp; controls TRANSPARENT property and easily switch between macOS having transparency on and Windows having it off.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Enjoy !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the IDE you can create constants. And if you create them as string constants you can set them to be &#8220;localized&#8221; or not. This gives you the ability to support multiple different languages in a single build as the localized language files will be saved and used by your application. But what happens to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.great-white-software.com\/blog\/2020\/07\/13\/dynamic-const-or-not\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Dynamic const or not ?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-799","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/comments?post=799"}],"version-history":[{"count":1,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/799\/revisions"}],"predecessor-version":[{"id":800,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/799\/revisions\/800"}],"wp:attachment":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/media?parent=799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/categories?post=799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/tags?post=799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}