On 08/03/2011 09:03 PM, Benoît Minisini wrote: >> On 08/03/2011 08:09 PM, Benoît Minisini wrote: >>>> On 08/03/2011 07:00 PM, Kevin Fishburne wrote: >>>>> I need to create a public array in a module but specify its dimensions >>>>> in a procedure later. Is this possible, and how would it be done >>>> I forgot to mention, I'd like it to be a 2D array, though I could write >>>> workaround code if it has to be 1D. >>> You have to specify the array dimensions at the same time you create it. >>> So you have to create it in your later procedure. >> Hmmm. It's been my experience that public variables have to be declared >> at the top of a module outside of the procedures and that Dim needs to >> be used inside procedures. Is there some way around this? The variables >> which determine the number of dimensions of the array are calculated >> from values input by the user, but need to be persistent and accessible >> from multiple separate procedures. If it's not possible I'll make it 1D >> and use code so that it can be treated as 2D, dimensioning it to >> "maximum realistic size" when it's created. > "Normal" arrays are entirely dynamic. So you can declare the variable that > will own the reference to the array somewhere: > > ' Module SomeWhere > > Public MyArray As Float[] > > ' Module SomeWhereElse > > Private Sub CreateArray(X As Integer, Y As Integer) > > SomeWhere.MyArray = new Float[X, Y] > > End Sub > > ' Module InAnotherDimension > > Private Sub DoSomeStuff() > > Dim X, Y As Integer > > X = SomeWhere.MyArray.Bounds[0] > Y = SomeWhere.MyArray.Bounds[1] > > ... > > End
That is fantastic, thank you. It's amazing how little I really know about programming. I'm surprised I get as much accomplished as I do. :) -- Kevin Fishburne Eight Virtues www: http://sales.eightvirtues.com e-mail: sa...@eightvirtues.com phone: (770) 853-6271 ------------------------------------------------------------------------------ BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA The must-attend event for mobile developers. Connect with experts. Get tools for creating Super Apps. See the latest technologies. Sessions, hands-on labs, demos & much more. Register early & save! http://p.sf.net/sfu/rim-blackberry-1 _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user