(no subject)
Author Message
(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

matt
\

Wed, 18 Jun 1902 08:00:00 GMT
(no subject)

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

>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.

Regards,
William of HKTC(TY).

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

Wed, 18 Jun 1902 08:00:00 GMT
(no subject)

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
}>
}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.
--

Wed, 18 Jun 1902 08:00:00 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages
 10. (no subject) 11. (no subject) 12. (no subject)