Board index » delphi » I need Turbo Pascal 7.0 help.

I need Turbo Pascal 7.0 help.

I have just recently started programming in TP7 and already I'm
stuck on a simple assignment.The assignment is to write a function that
takes hours and minutes as parameters and returns seconds does anyone
out there have a clue on how I can write it.

 

Re:I need Turbo Pascal 7.0 help.


Quote
larry hale wrote:

> I have just recently started programming in TP7 and already I'm
> stuck on a simple assignment.The assignment is to write a function that
> takes hours and minutes as parameters and returns seconds does anyone
> out there have a clue on how I can write it.

function GetSeconds(Hours : longint;
                    Minutes : longint) : LongInt;
begin
  GetSeconds := ((Hours * 60) * 60) + (Minutes * 60);
end;

--
Joe C. Hecht
(Borland Delphi Developer Support)
Join the Delphi Online Discussion Forum at
http://www.borland.com/techsupport/delphi/

Re:I need Turbo Pascal 7.0 help.


Quote
larry hale <sidew...@arkansas.net> wrote:
>I have just recently started programming in TP7 and already I'm
>stuck on a simple assignment.The assignment is to write a function that
>takes hours and minutes as parameters and returns seconds does anyone
>out there have a clue on how I can write it.

Larry, I can't believe you can't figure out how to do this
simple task.  First, figure out how you would do the task.
Then translate your solution to Pascal.  The translation
will look something like:

FUNCTION Seconds(Hours, Minutes: Integer): Integer;
VAR Result: Integer;
BEGIN
    <-- you have to put your solution here -->
       <-- store your answer in result -->
    Seconds := Result;
END;

    ...red

Re:I need Turbo Pascal 7.0 help.


In article <33492D85....@corp.borland.com> of Mon, 7 Apr 1997 12:23:17
in comp.lang.pascal.borland, "Joe C. Hecht" <jhe...@corp.borland.com> (*

Quote
of Delphi *) wrote:
>larry hale wrote:

>> I have just recently started programming in TP7 and already I'm
>> stuck on a simple assignment.The assignment is to write a function that
>> takes hours and minutes as parameters and returns seconds does anyone
>> out there have a clue on how I can write it.

>function GetSeconds(Hours : longint;
>                    Minutes : longint) : LongInt;
>begin
>  GetSeconds := ((Hours * 60) * 60) + (Minutes * 60);
>end;

Does Delphi optimise that code to match
   GetSeconds := (Hours * 60  + Minutes) * 60 ;   ?
BP7, it seems, does not.

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web URL: http://www.merlyn.demon.co.uk/ -- includes FAQqish topics and links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
  Before a reply, quote with ">" / "> ", known to good news readers (SoRFC1036)

Other Threads