"Declaration Expected"


[ Delphi Forum ] [ Delphi Tutorials -- by DelphiLand ]

Posted by Jeff Duff on September 04, 2003 at 16:25:29:

I'm totally lost on these error messages.

I have this function, that takes an amount of Seconds, and convertes it to how many weeks, days, hours, minutes and seconds it is.

function Duration(Secs : Extended) : string;
var
intWeeks : integer;
intDays : integer;
intHours : integer;
intMinutes : integer;
intSeconds : integer;
begin
intWeeks := 0;
intDays := 0;
intHours := 0;
intMinutes := 0;
intSeconds := 0;

if Secs >= 604800 then //Seconds in a month
begin
intWeeks := Trunc(Secs / 604800);
Secs := Secs - (intWeeks * 604800);
end;

if Secs >= 86400 then //Seconds in a day
begin
intDays := Trunc(Secs / 86400);
Secs := Secs - (intDays * 86400);
end;

if Secs >= 3600 then //Seconds in a hour
begin
intHours := Trunc(Secs / 3600);
Secs := Secs - (intHours * 3600);
end;

if Secs >= 60 then //Seconds in a minute
intMinutes := Trunc(Secs / 60);
Secs := Secs - (intMinutes * 60);
end;

intSeconds := Truc(Secs); //The Rest should be seconds

Result := IntToStr(intWeeks) + ' Weeks ' + IntToStr(intDays) + ' Days ' + IntToStr(intHours) + ' Hours ' + IntToStr(intMinutes) + ' Minutes ' + IntToStr(intSeconds) + ' Seconds';
end;


Related Articles and Replies:


[ Post Followup ] [ Delphi Forum ]
[ DelphiLand: free Delphi source code, tips, tutorials ]