Board index » delphi » (no subject)

(no subject)

Does anyone know how to get the current time from the system, as an
integer? (in turbo pascal 7.0)..i need this for a random number
generator (our teacher is not allowing us to use the built-in one)

many thanks
please write to <mb...@capaccess.org> as soon as possible.

matt
\

 

Re:(no subject)


In article <4apfk2$...@pecf.cathedral.org>,
   Matt Buas <mb...@capaccess.org> wrote:
Quote
>Does anyone know how to get the current time from the system, as an
>integer? (in turbo pascal 7.0)..i need this for a random number
>generator (our teacher is not allowing us to use the built-in one)

>many thanks
>please write to <mb...@capaccess.org> as soon as possible.

>matt
>\

It is easy, you first need to get the time (hour, minute, second,
hundred_second) in the form of WORD using system predefine procedure gettime,
then you can convert it to integer by an assignment statement. Since hour,
minute, second, hundred_second would less than 100, these convertion will not
cause overflow error. If your compiler does not allow you to convert a word to
an integer, try the following,

                a := integer(b);

the above statement works only on Borland Pascal and Microsoft Pascal.

I hope this can help you.

                                        Regards,
                                        William of HKTC(TY).

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<Fastest return e-mail : w...@interserve.com.hk>
<Second return e-mail  : Lee.Wing.Kin.Will...@mccatholic.yonet.org>

William is a student of Hong Kong Technical College (Tsing Yi)

Re:(no subject)


In article <4bolro$...@inter.interserve.com.hk>
           w...@interserve.com.hk "William of HKTC" writes:

Quote
}In article <4apfk2$...@pecf.cathedral.org>,
}   Matt Buas <mb...@capaccess.org> wrote:
}>Does anyone know how to get the current time from the system, as an
}>integer? (in turbo pascal 7.0)..i need this for a random number
}>
}It is easy, you first need to get the time (hour, minute, second,
}hundred_second) in the form of WORD using system predefine procedure gettime,

On a PC, there's an easier way.  Uninterruptibly read the
longint/longword count at $40:$6C (use Seg0040 in BP7 DPMI
mode) and divide by a "well-known" constant (about 18.2)
to get seconds.  For a random number, of course, uninterruptible
and divide are not needed.
--
Dr John Stockton, Surrey, UK -- J...@merlyn.demon.co.uk -- SNews & PCElm

Other Threads