[Gambas-user] Global multidimensional arrays
gambas at ...1...
Mon May 9 16:17:40 CEST 2005
On Saturday 07 May 2005 14:11, ML wrote:
> Hi all,
> a few days ago I came across Gambas and the more I discover about it the
> more I like it!
> Congratulations to all the developers for their very neat, promising
> Having started coding some test applications, I have a problem though that
> I haven't been able to solve by trial and error and also by looking at the
> documentation and in the ML.
> It could just be a matter of poor experience and practice with Gambas but I
> have yet to find a solution.
> The problem is that I need to have a global bidimensional array of floats,
> available through all modules and classes.
> According to the help file,
> "There is no such thing as a project-wide global variable in Gambas. As a
> workaround, consider making a class called Global and declaring your global
> variables as static public variables in that class, and then referring to
> them as Global.variablename in your project. It's still poor programming
> practice but at least they'll be identified as global variables whenever
> you use them".
> That's exactly what I've tried to do, but if I create a Global class and
> declare in it a "static public P[5,5] as float", when trying to compile the
> code, I get a "Arrays are forbidden here at line xx in Global class" error.
> So, if arrays are forbidden here, how can I overcome this problem?
> TIA for your help,
In gambas, there two types of arrays:
- Static array, that are allocated inside the object when they are private to
them. They can't be public.
- Dynamic arrays, that are true Gambas objects, and that work like arrays in
Java. They can be public.
In the development version, dynamic arrays can be multi-dimensional. So you
can write now:
STATIC PUBLIC p AS Float
and in the contructor:
p = NEW Float[5, 5]
At the moment, you can't write directly STATIC PUBLIC p AS NEW Float[5, 5]
mailto:gambas at ...1...
More information about the User