Re: [fpc-pascal] Arrays of objects

2007-10-31 Thread Adrian Maier
On 10/31/07, Marco van de Voort <[EMAIL PROTECTED]> wrote: > > On 10/31/07, Joao Morais <[EMAIL PROTECTED]> wrote: > > > They are reference counted, just like ansi strings, ie don't worry about > > > memory leakages. > > > > The detail that is not crystal clear to me is : after the first SetLengt

Re: [fpc-pascal] Arrays of objects

2007-10-31 Thread Marco van de Voort
> On 10/31/07, Joao Morais <[EMAIL PROTECTED]> wrote: > > They are reference counted, just like ansi strings, ie don't worry about > > memory leakages. > > The detail that is not crystal clear to me is : after the first SetLength > and i set the first 3 elements , is it *guaranteed* that th

Re: [fpc-pascal] Arrays of objects

2007-10-31 Thread Joao Morais
Lourival Mendes wrote: SetLength(Vetor, 2) Vetor[0]:= 1 Vetor[1]:= 2 As you can see you don't lose the first 2, After that you want 4 elements on the same variable: SetLength(Vetor, 4) If you print the variable, before associate any value to it you will get: Vetor[0]:= 1

Re: [fpc-pascal] Arrays of objects

2007-10-31 Thread Lourival Mendes
Dear Joao, I do beleive that the SetLength only resize the array, ie: The Vetor has 3 elements like: Vetor[0]:= 1 Vetor[1]:= 2 Vetor[2]:= 3 And then eu want the same variable but with only 2 element, then SetLength(Vetor, 2) Vetor[0]:= 1 Vetor[1]:= 2 As you can see you

Re: [fpc-pascal] Arrays of objects

2007-10-31 Thread Joao Morais
Adrian Maier wrote: On 10/31/07, Joao Morais <[EMAIL PROTECTED]> wrote: Adrian Maier wrote: On 10/31/07, Matt Emson <[EMAIL PROTECTED]> wrote: Adrian Maier wrote: Hello, I'm seeking for advice about which is the best way to hold an array of class instances I need to access the elements using

Re: [fpc-pascal] Arrays of objects

2007-10-31 Thread Joao Morais
Marco van de Voort wrote: Adrian Maier wrote: VArray: array of TSomeClass; begin SetLength(VArray, 10); // now you have VArray[0] .. VArray[9]; SetLength(VArray, 20); // now you have [0] .. [19]; // Length(VArray) = 20 // for I := 0 to Pred(Length(VArray)) is a valid statemen

Re: [fpc-pascal] Arrays of objects

2007-10-31 Thread Matt Emson
Marco van de Voort wrote: Adrian Maier wrote: VArray: array of TSomeClass; begin SetLength(VArray, 10); // now you have VArray[0] .. VArray[9]; SetLength(VArray, 20); // now you have [0] .. [19]; // Length(VArray) = 20 // for I := 0 to Pred(Length(VArray)) is a valid statemen

Re: [fpc-pascal] Arrays of objects

2007-10-31 Thread Adrian Maier
On 10/31/07, Joao Morais <[EMAIL PROTECTED]> wrote: > Adrian Maier wrote: > > On 10/31/07, Matt Emson <[EMAIL PROTECTED]> wrote: > >> Adrian Maier wrote: > >>> Hello, > >>> > >>> I'm seeking for advice about which is the best way to hold an array of > >>> class instances > >>> I need to access the

Re: [fpc-pascal] Arrays of objects

2007-10-31 Thread Marco van de Voort
> Adrian Maier wrote: >VArray: array of TSomeClass; > begin >SetLength(VArray, 10); >// now you have VArray[0] .. VArray[9]; >SetLength(VArray, 20); >// now you have [0] .. [19]; >// Length(VArray) = 20 >// for I := 0 to Pred(Length(VArray)) is a valid statement > > The

Re: [fpc-pascal] Arrays of objects

2007-10-31 Thread Joao Morais
Adrian Maier wrote: On 10/31/07, Matt Emson <[EMAIL PROTECTED]> wrote: Adrian Maier wrote: Hello, I'm seeking for advice about which is the best way to hold an array of class instances I need to access the elements using its position (like a regular array) , and also i'd like the structure to

Re: [fpc-pascal] Arrays of objects

2007-10-31 Thread Adrian Maier
On 10/31/07, Matt Emson <[EMAIL PROTECTED]> wrote: > Adrian Maier wrote: > > Hello, > > > > I'm seeking for advice about which is the best way to hold an array of > > class instances > > I need to access the elements using its position (like a regular > > array) , and also i'd like > > the structur

Re: [fpc-pascal] Arrays of objects

2007-10-31 Thread Matt Emson
Adrian Maier wrote: Hello, I'm seeking for advice about which is the best way to hold an array of class instances I need to access the elements using its position (like a regular array) , and also i'd like the structure to grow when I add more elements TObjectList If you want specific non type

[fpc-pascal] Arrays of objects

2007-10-31 Thread Adrian Maier
Hello, I'm seeking for advice about which is the best way to hold an array of class instances I need to access the elements using its position (like a regular array) , and also i'd like the structure to grow when I add more elements. Fpc has 'dynamic arrays' , and also there several classes li