I’m lost on how to add a global variable to a method. I’m not using classes or properties. Coming from a VB6 background I’m used to having a module and placing code at the module level. Not within a procedure within the module. After creating a module, I can’t add code to it. I have to create a method to do that.
For example, I want to define these arrays at a window module level and allow access to any code within the window module. For a control on the window, any of the control events should be able to use the window level variable.
Var m1(1,1) As Integer
Var m2(1,1) As Integer
Var ResultMatrix(1,1) As Integer
There’s no such thing as a “Window Module” in Xojo. If you add a module to a Xojo project, any methods, constants or properties in the module whose Scope is set to “Global” are available to code anywhere in the app.
Any properties, methods, or constants added to a Window via the IDE are accessible to any code in that window. They can be accessed by other objects in the app if their scope is set to Public.
Any properties or constants declared within a method in a window are only accessible within that method.
Did not know that module variables are called properties.
I added a property, but I don’t see how to make the property a multi dimensional array. If I use (,) for type, xojo changes it (
You can use whatever dimensions you want in the Inspector definition, and you can redimension the array later with
ReDim Foo(10,10)
later if needed. Note you cannot append values to a multi-dimensional array like you can with a 1-dimensional array - the dimensions are fixed unless you re-dim. For this reason I almost never use multidimensional arrays, I use classes having 1-dimensional arrays as class properties.