Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with 'Mean' function? 1

Status
Not open for further replies.

corsair2

IS-IT--Management
Feb 21, 2001
55
0
0
GB
I have the following piece of code which throws up the error 'Missing operator or semicolon'. The cursor is placed at the start of the 'ExArray' within the brackets.
Any ideas?

var
ExArray: array[1..100] of double;
i: integer;
begin
Randomize;
for i:=1 to 100 do
begin
ExArray:=(Random-Random)*100;
end;
Mean(ExArray);
 
hi

Think you may be missing your result variable for the Mean function.

var
ExArray: array[1..100] of double;
i: integer;
answer : extended;
begin
Randomize;
for i:=1 to 100 do
begin
ExArray:=(Random-Random)*100;
end;
answer := Mean(ExArray);
:

 
Thanks for the prompt response!
However, having edited the code with your suggestion the error is still there.
This really has me beat!

Regards

Steve
 
hi

Just done a quick app and this worked for me (added Math to the uses):-

procedure TForm1.Button1Click(Sender: TObject);
var
ExArray: array[1..100] of double;
i: integer;
answer : extended;
begin
Randomize;
for i:=1 to 100 do
begin
ExArray:=(Random-Random)*100;
end;
answer := Mean(ExArray);
label1.Caption := floattostr(answer);
end;


You are missing an 'end' on the end but I thought you may have more code afterwards.

 
Thanks Lucie

have copied your code to my form and it works fine!
Think I'll just have to put this one down to experience...
Strange thing is, the original works fine with MeanAndStdDev function!

Regards

Steve
 
hi

Glad you've sorted it. Funny thing is I copied your code from here and just put it in the event and added the 2 lines on the bottom.

All the best
lou

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top