Assigning new array values

Questions about MultiCharts and user contributed studies.
Posts: 43
Joined: 01 Dec 2008
Has thanked: 2 times
Been thanked: 2 times

Assigning new array values

Postby RWDickinson » 17 Apr 2009

A question I can't seem to answer from the docs:
Using MC 4.0.
I have a dynamic array of numeric values. How do I add a new value to the array? Do I have to keep track of the current "end" number and assign to "end+1"? or can I create a new element at 0 so that the latest entry is [0] and the next before that is [1] (like the built-in arrays)?

I've just discovered that if doing the "end+1" method I have to set the MaxIndex values myself.(?) How very 1960's of the language designers.
I'd rather add new entries at [0], but I don't see a way to do that.

I've got my system working now, so I guess no replies needed unless you want to make comments.

User avatar
Andrew Kirillov
Posts: 1589
Joined: 28 Jul 2005
Has thanked: 2 times
Been thanked: 31 times

Postby Andrew Kirillov » 20 Apr 2009

Resizes a declared dynamic array to a specified number of elements; returns a value of True to indicate a successful resize.
An array can be resized to a larger or to a smaller number of elements; any elements added to an array will be assigned the initial value that was specified at array declaration.

Where: ArrayName - an expression specifying the name of an array to be resized
MaxIndex - a numerical expression specifying the maximum index of the array*

*Array indexes start at 0, and array size is equal to the value of MaxIndex plus one.
True - resize sucessfull

False - resize failed
Resize the dynamic array Array1 to 10 elements by specifying a maximum index value of 9:


Assign a value that indicates a status of the resize of Array1 to the ResizeReport variable:


A value of True will indicate a successful resize, and a value of False will indicate a failed resize.

Return to “MultiCharts”