array populated by a function and used outside of function

Questions about MultiCharts and user contributed studies.
ts2mc
Posts: 122
Joined: 12 Jan 2009
Been thanked: 1 time

array populated by a function and used outside of function

Postby ts2mc » 21 Jan 2009

hello experts,
i need a function that populates an array.
my problem is:
it seems functions can't return array values.
it seems function can't accept array as parameter type.

so, what is the solution please in order to populate an array
and to use this array outside the function.


thank you

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 22 Jan 2009

Hi ts2mc,

An array can be passed into a function as an input. Or you can pass an array itself with its values. For example:

Code: Select all

input: my_array[MAXSIZE](numericarray);
An array can also be passed through a reference (which is what you're looking for):

Code: Select all

input: my_array[MAXSIZE](numericarrayref);
In this case an array passed to a function can be processed within the function's body:

Code: Select all

input: my_array[MAXSIZE](numericarrayref);
input: array_size(numericsimple);
for value1 = 0 to array_size begin
my_array[value1] = value1;
end;
Hope the above helps.

ts2mc
Posts: 122
Joined: 12 Jan 2009
Been thanked: 1 time

Postby ts2mc » 22 Jan 2009

Hello Marina,
thank you very much (especially for reference tip)
2 comments:
- MAXSIZE is nowhere explained (what is its value ?)
- it seems powerlanguage excepts only maxsize


Return to “MultiCharts”