How to record the values of a variable in an array

Hi!
My question is, can I a record the values of a variable in an array?, for example I have an analog read that change with the time and I want to record the values of that variable in an array.

Is there any method or something?
Regards.

Dim myArray(-1) As Interger

MyArray.append newVarValue

FYI, You can leave out “-1” for shorthand.

dim myArray() as Integer

Naturally you can specify a number of elements upfront too, if you know what it will be, but that statement expects a literal or a constant.

dim myArray( 4 ) as Integer

That will create an array with five elements (0 thru 4).

You can also populate the values initially with the Array function:

dim myArray() as Integer = Array( 10, 20, 30, 40 )

Finally, you can append as Roger suggested or you can resize an array in one shot if you have the new size is in some variable:

dim myArray() as Integer
redim myArray( newSize )

Increasing the size this way will add new slots initialized to zero, nil, or empty, depending on the type of array. Redim’ing down till drop off the elements past the new size.

You should read:

http://documentation.xojo.com/index.php/Array

Thanks Roger and Kem, It was very useful! :smiley: