Re: "Declaration Expected"
[ Delphi
Forum ] [ Delphi Tutorials -- by DelphiLand ]
Posted by WAllison on September 04, 2003 at 17:03:47:
In Reply to: Re: "Declaration Expected" posted by Jeff Duff on September 04, 2003 at 16:28:03:
: Ack, hit tab and it pressed Send! : Anyway the errors are: : [Hint] test.pas(96): Value assigned to 'Secs' never used : [Hint] test.pas(74): Value assigned to 'intSeconds' never used : [Hint] test.pas(72): Value assigned to 'intHours' never used : [Hint] test.pas(71): Value assigned to 'intDays' never used : [Hint] test.pas(70): Value assigned to 'intWeeks' never used : [Error] test.pas(99): Declaration expected but identifier 'intSeconds' found > : [Error] test.pas(102): '.' expected but ';' found : [Fatal Error] test1.dpr(5): Could not compile used unit 'test.pas' you missed out a begin m8 the last If should be if Secs >= 60 then //Seconds in a minute begin intMinutes := Trunc(Secs / 60); Secs := Secs - (intMinutes * 60); end; The whole thing: 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 begin intMinutes := Trunc(Secs / 60); Secs := Secs - (intMinutes * 60); end; intSeconds := Trunc(Secs); //The Rest should be seconds Result := IntToStr(intWeeks) + ' Weeks ' + IntToStr(intDays) + ' Days ' + IntToStr(intHours) + ' Hours ' + IntToStr(intMinutes) + ' Minutes ' + IntToStr(intSeconds) + ' Seconds'; end;
[ Delphi
Forum ]
[ DelphiLand: free Delphi source code, tips, tutorials ]
|