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
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
MyWindow.MyTextArea.Text=“Anything” #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.
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.