[Gambas-user] About help and arrays and variables
Fabien Bodard
gambas.fr at ...626...
Fri Nov 19 14:01:02 CET 2010
2010/11/19 Demosthenes Koptsis <demosthenesk at ...626...>:
> On Fri, 2010-11-19 at 01:38 +0100, Benoît Minisini wrote:
>> > Can someone explain embedded arrays further?
>> >
>> > i understand nothing.
>> >
>> > i know what a normal array is and that it can be static or dynamic.
>> >
>> > But "embedded arrays are just a way to access a part of a Gambas object"
>> >
>> > for example i have a TextBox1 how can i use an embedded array on it?
>> >
>> > You mean do use the TextBox1 as an array..? For example to enumerate its
>> > properties? i cant think what do you mean.
>> >
>> > If there is an example to demonstrate the differences. Please.
>> >
>>
>> First, have you read the documentation page about Gambas object model?
>>
>
> Yes i did. But i try to understand.
>
> Thanks Fabien!
>
> So
>
> 1) PRIVATE aInt1[3] AS Integer
> is an embedded array of integers with 3 elements in an object for
> example FMain.
>
> 2) DIM iFieldr AS NEW Integer[9]
> is a static array of integers with 9 elements
>
> 3) Also PRIVATE Languages AS String[] = [ "fr", "it", "es", "de", "ja" ]
> is a static !!!
no ..dynamic ... you are assigned a dynamic array = [...]
in fact [...] generate an array and you assign it's internal ref to
the variable string array Languages
> (so far i thought that this was a dynamic array, because it was declared
> with no dimensions PRIVATE Languages AS String[])
>
> 4) A dynamic array has global reference, where is it declared ?
in intern ... it's a pointer
but in the reallity it act like a normal variable
private/public/static/ and local
>
> A dynamic array declaration how is it?
private aMyArray as new Integer[]
but it can be too
private aLabels as new Label[]
this is dynamic array, there are all herited of the array class, witch
allow to add, resize (preserve), remove, etc
some class in dynamic array have some extents like .sort or .find
>
> Example?
>
>
> ps:
> so far i knew that
> 1) a static array has fixed dimensions, cannot be resized
yes
> 2) a dynamic array can be resized, has no static dimensions.
> so i thought a
> DIM aInt AS Integer[5] is a static
> and
> PRIVATE aInt AS Integer[] is a dynamic
yes
> but i saw that in both declarations i can do
>
> aInt.Add(6) and to add éléments.
no AND YOU'VE FOUND A BEAUTIFUL BUG IN THE IDE :)
if you try that and exec it generate an error and say "static array"
>
> The terminology of static and dynamic is different in Gambas or i am
> wrong again?
no i think it's the same as other language
>
> 2010/11/19 Fabien Bodard <gambas.fr at ...626...>:
>> http://gambasdoc.org/help/cat/objectmodel
>>
>> http://gambasdoc.org/help/cat/arraydecl
>>
>> Ok so,
>>
>>
>> an embedd array is a private array...
>>
>>oups i forgot to read this line in the help :
>>
>>"In Gambas 3, embedded arrays cannot be used as local variables
>>anymore. But they can be public!"
>>
>>so the only advantage to static array i see it's that they die with
>>the object :)
>>
>> you cannot give it as argument throw a procedure ex :
>>
>> Public mysub(myVar as MyArray[])
>>
>> Like we can do with a dynamic array that have global reference such as
>> any objects
>>
>>
>> The embedd array have the same memory space than the object into it is
>> initialized... so it die with this object
>>
>>
>> A dynamic array will be alive all the time it is referenced somewhere
>> in the project. like any gambas objects.
>>
>>
>> Yes i prefer dynamics one ... and i think , like Benoit i don't use
>> static one any more.
>>
>>
>> Le 19 novembre 2010 01:38, Benoît Minisini
>> <gambas at ...1...> a écrit :
>>>> Can someone explain embedded arrays further?
>>>>
>>>> i understand nothing.
>>>>
>>>> i know what a normal array is and that it can be static or dynamic.
>>>>
>>>> But "embedded arrays are just a way to access a part of a Gambas
> object"
>>>>
>>>> for example i have a TextBox1 how can i use an embedded array on it?
>>>>
>>>> You mean do use the TextBox1 as an array..? For example to enumerate
> its
>>>> properties? i cant think what do you mean.
>>>>
>>>> If there is an example to demonstrate the differences. Please.
>>>>
>>>
>>> First, have you read the documentation page about Gambas object
> model?
>>>
>>> --
>>> Benoît Minisini
>>>
>>>
> ------------------------------------------------------------------------------
>>> Beautiful is writing same markup. Internet Explorer 9 supports
>>> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
>>> Spend less time writing and rewriting code and more time creating
> great
>>> experiences on the web. Be a part of the beta today
>>> http://p.sf.net/sfu/msIE9-sfdev2dev
>>> _______________________________________________
>>> Gambas-user mailing list
>>> Gambas-user at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>>
>>
>>
>>
>> --
>> Fabien Bodard
>>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
Fabien Bodard
More information about the User
mailing list