[Pas2js] how to work with dynamic arrays
Michael Van Canneyt
michael at freepascal.org
Sat Oct 17 12:35:32 CEST 2020
On Sat, 17 Oct 2020, Mgr. Janusz Chmiel wrote:
> Because dynamic arrays are very important, how to work with them.
> If I will declare
> var
> a: array of string;
> How could I add several values to this dynamic array?
> because a (1) :='ahoj';
You must set the size first.
// Allocate 10 elements
SetLength(a,10):
// Array is zero based.
a[0]:='ahoj';
a[1]:='hello';
...
a[9]:='The last of the Mohicans';
Michael.
More information about the Pas2js
mailing list