rand unit (was: us_Timer in TimeStamp)_(re)
Tue, 28 Oct 97 07:13:25 -0400
On Mon, 27 Oct 1997 16:47:56 +0100 (MET), Peter Gerwinski wrote:
>On 21 September, Frank Heckenbach posted a Unit `Rand' to this list
>which implements a `random' and a `randomize' function just this
>way. You can extract it from the GPC mailing list archives (see
>http://home.pages.de/~GNU-Pascal/support.html) or download it from
>ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/contrib/rand.pas.
IMHO, this code is still broken. On a non-DOS platform it tries to
pass an integer to a function expecting a cardinal and always returns a
type check error and doesn't compile. Is there some advanced switch
that should be used in situations like this to turn off type-checking
(I've never really looked at all of the directives and didn't see where
they were in the docs after a quick look) and the type-casting section
is empty.
The code in question:
FUNCTION Rand:Integer; C;
PROCEDURE SRand(Seed:Cardinal); C;
FUNCTION GetPID:Integer; C;
PROCEDURE Randomize;
BEGIN
SRand(GetPID);
RandSeed:=Rand
END;
-Kevin
--
Kevin A. Foss --- kfoss@mint.net
--
Kevin A. Foss (kfoss@mint.net)
HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada -
Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es