ParanoidParrot
ParanoidParrot

Reputation: 41

Pascal doesn't write the result in the text file

program Noname4;

 function minutes (Amin, Bmin :integer) : integer;
 function time (Aval, Bval :integer) : integer;
 begin
   if (0 <= Aval) and (Bval < 24) then
     time :=Bval - Aval;
   if (0 <= Amin) and (Bmin < 60) then
     minutes :=Bmin - Amin;
 end;
 var Aval, Bval, n , x , i , y :integer;
    duom, rez : text;
 begin
  assign(duom, 'Duomenys2.txt');
  Reset(duom);
  Readln(duom, n );
  assign(rez, 'Rezultatai2.txt');
  rewrite(rez);
  for i := 1 to n do
  begin
    Readln(duom, Aval, Bval, Amin, Bmin);
    x := time(Aval, Bval);
    y := minutes(Amin, Bmin);
    writeln(rez, x);
    writeln(rez, y);
   end;
 close(duom);
 close(rez);
 end;
 begin
 end.

The program works fine, no errors but doesn't write the result in the (Rezultatai2.txt) file. I think it doesn't read the assigned file (Duomenys2.txt) because I write there whatever I want and it still works.

Upvotes: 0

Views: 268

Answers (1)

Ondrej Tucny
Ondrej Tucny

Reputation: 27974

Your program is effectively empty. There is no code between the program's begin / end. Hence your program when executed, even though it compiles fine and causes no run-time errors, doesn't do anything useful.

Upvotes: 3

Related Questions