-1

I tried to check for the initial elements of the four arrays but the system is throwing a default value which is .000. It looks like the loop is running but still the value of all the elements is not changing. Please have a look!

var
  Form1: TForm1;
  n_max : integer;
  n: integer;
  r, R1, f, h0 : Array of Real;

const
  h = 0.00889; nip= 100;
  cod = 10;
  rod = 76;
  nip_dia = 5; viscosity = 0.001; velocity = 76;


implementation

{$R *.dfm}


    procedure TForm1.Button1Click(Sender: TObject);
    begin

       n_max := Round(((rod-cod)/2)/h);
       Setlength(r, n_max);
       Setlength(f, n_max);
       Setlength(h0, n_max);
       Setlength(R1, n_max);

       for n := 0 to n_max-1 do;

        r[n]:= cod/2 + h*n;
        R1[n] := (r[n]*(nip_dia)/2)/(r[n]+(nip_dia)/2);
        f[n] := nip*((r[n]-r[0])/r[n]);
        h0[n] :=4*viscosity*velocity*(1/(60*(R1[n]/f[n])));


       Edit1.Text := FormatFloat('#.00', r[1]);
       Edit2.Text := FormatFloat('#.00', f[1]);
       Edit3.Text := FormatFloat('#.00', h0[1]);
       Edit4.Text := FormatFloat('#.00', R1[1]);


    end;

    end.
9
  • There's nothing in the body of your for loop.
    – overactor
    Jun 10, 2014 at 9:45
  • The loop is stopped at do;. It should start a begin end block.
    – LU RD
    Jun 10, 2014 at 9:47
  • I tried the begin end but still it's throwing the same .00 value
    – Vivek30
    Jun 10, 2014 at 9:49
  • Are you sure you didn't misplace a ; when you tried begin end?
    – overactor
    Jun 10, 2014 at 9:52
  • You made the same mistake at your last question. This was explained to you. Please re-read the answer to your last question. Jun 10, 2014 at 9:54

1 Answer 1

1

Your loop is not running. It is terminated by do;. You need to enclose the loop calculations by a begin/end block.

It should be:

for n := 0 to n_max-1 do
begin
  r[n]:= cod/2 + h*n;
  R1[n] := (r[n]*(nip_dia)/2)/(r[n]+(nip_dia)/2);
  f[n] := nip*((r[n]-r[0])/r[n]);
  h0[n] :=4*viscosity*velocity*(1/(60*(R1[n]/f[n])));
end;

See documentation For Statements.

Not the answer you're looking for? Browse other questions tagged or ask your own question.