Greetings,
I have a class that has several properties. Example:optic(1).price=23000 In one window’s event and in a method the assignment work. However, in a second window c… is not recognized. Please help. Thanks
Greetings,
I have a class that has several properties. Example:optic(1).price=23000 In one window’s event and in a method the assignment work. However, in a second window c… is not recognized. Please help. Thanks
I messed up the example: Let me try again using the attached pic. OpticData Set has ClassOpticData as its super with its associated properties. The super for ClassOpticData is xojo.point (I don’t want a control on the desktop) Window: Optics2025 sees OpticData.property, WindowPrism does not. Now, maybe you can help. Thanks!
Create an example that reproduces your problem, zip it and upload it here for someone to take a look.
At least, I can’t figure from your information/images what could be wrong.
If you have an instance of your class held in a window property it will not be accessible from other windows unless a) the instance and its methods or properties you’re trying to access are public in scope, and b) you specify the full address of the property or method, e.g. Optics2025.OpticData(0).SomeProperty
, which would work (if Optics2025 is open or has ImplicitInstance set to True) but not be great OOP practice.
Thanks for your help. I found a way, but a bit burdensome. I have a class that holds my data for an optic using 12 properties. For each window there is a generic controller of different names that sees this class with its 12 properties. Using a module with a method that equates the two sets of data, each window knows the properties. It would be nice if a data set for a class could be global. Maybe it can be???
Thanks again!
Carl
Not sure I understood but are you looking for a Shared property?
In a desktop app you can store the instance of the class in a property of the App object. Then any element can access the class. For a Web app you can add it to the Session object.
Or in a module. But I think Jeremy may have hit on what the OP is getting at - it seems he wants class properties, not instance properties, to be accessible globally. “A generic controller of different names that sees this class with its 12 properties”
If there are only ever these 12 properties then both designs are functionally equivalent. The difference only comes into play if there are other none shared properties. There’s slightly less effort involved in only creating the instance of the class once. Rather than multiple instances, which have to be created and destroyed for each window.
I am still confused about what the OP is asking for. Do you want one instance of the class that is shared among the windows? Or do you want an individual instance of the class for each window that can then be compared/aggregated later on?
Greetings all,
I am looking for class instances to be shared between several windows. I think I have found the answer. If I put the class in the App then any instance with its associated properties will be available throughout the app.
Ian and Tim you are correct, I want to create multiple instances that can hold data in properties of that class that are usable within several methods of multiple windows. There will be multiple graphicsPath elements that have to be repeatedly drawn.
example: Dim OD As New OpticData
OD(8).indexOfRefraction=1.8
Thanks
You can also use modules to create more structure and order and not have to pack everything into the App. Modules can also be nested hierarchically.