A
A
andrey_levushkin2020-04-06 14:02:47
Pascal
andrey_levushkin, 2020-04-06 14:02:47

How to pass variables and arrays to a function?

There are 2 global arrays and a variable

var 
 mas, masX: array[0..5]of real;
 x,y:real;


Have a function

function Z(x: real): real;
begin
...
end;


Both arrays must be passed to the function (with the possibility of change). How to do it from program code? The function itself takes the form
function Z(a: real; var mas1,mas2:array of real): real;
begin
...
end;

I'm trying to access the function from the code
y := function Z(x,mas,masX);
But, apparently, the design is wrong. How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
HemulGM, 2020-04-06
@andrey_levushkin

You specified a dynamic array in the method (mas1,mas2:array of real), but you want to pass a static one array[0..5]of real;
Define a static array as a type

type
  TMyArray = array[0..5]of real;

var
  mas, masX: TMyArray;

function Z(a: real; var mas1,mas2:TMyArray): real;
begin
...
end;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question