Eternal module : compile code with window name that is not the curret app


i used many external module or class in different apps, I still have a problem i encouter when I want to execute code to update controls on a windowthat are not in the current app.

if i do

myWindow.myTextaera.text = “blabla”

compiler will refuse to compile because there’s no window

how can i do

if myApp = “oneApp” then

someString = “myWindow.myTextaera.text = “blabla””

execute someString

like pragmas ?
i’ve bumped into this problem before, if we can solve it…

You can’t do that in the way you’re thinking. Instead, create a property in the module named, for example, “targetWindow”, and have the app initialize it upon startup. Then, in your module, check to make sure self.targetWindow <> nil before using it.


What about adding a constant (to the app class, or another module), like CstProjectID and surround your code with:
#if app.CstProjectID=“ThisApp” then
#end if
Would it suits your needs?


yes thanks i did that, don’t know why i didn’t use it before !
is it because it is a app.constant that it can work ? a regular property in module wouldn’t work ? didn’t try

If you use a constant in another, non-exported, module, it’ll work the same (you’ll just have to remove the “app.” call, of course).
But if you try on the same module than where you had troubles (the exported one), your constant will be updated each time you open the module in another project, with the ID of the previously saved project. Not convenient, but error prone.

1 Like

i meant i have a module that i use in all my apps
if i put a property in my preference module, it will behave the same

i can do
#if anyVar = “ThisApp” then
#end if

? if yes , i found myself stupid for not using it before in my eternal classes !

Yes, exactly, this is what you’d do. My latest point was that AnyVar must not be in the same module.

Sometimes solutions are simpler than our thoughts :wink:

You are doing tight coupling between things that could be loosely coupled. If that sounds pornographic or you don’t know what tight coupling is please do a Goggle search.

You are creating something that is fragile. The module and the function need to get information or you should define a different way how to beam information from origin to destination.


just saw this from a french developper i follow

She makes interresting and well documented pages worth reading