%endoflist

!**  %routine   INITALISE RANDOM    sets up the random integer SEED          **!
!**  %real %fn  RANDOM REAL (LO,HI) returns uniformly distributed reals      **!
!**                                 between LO and HI inclusive              **!
!**  %short %fn RANDOM INT (LO,HI)  returns uniformly distributed short      **!
!**                                 integers between LO and HI inclusive     **!

%own %integer Seed


%routine Initialise Random
!
! Set up SEED
!
   Seed = CpuTime
%end


%realfn Random Real(%real Lo, Hi)
!
! Returns a random real between LO and HI inclusive
!
   Seed = (23501*Seed + 6923) & 32767
   %result = Lo + (Seed * (Hi - Lo))/32767
%end


%shortfn Random Int (%short Lo, Hi)
!
! Returns a random shortinteger between LO and HI inclusive
!
   Seed = (23501*Seed + 6923) & 32767
   %result = Int(Lo + (Seed * (Hi - Lo))/32767)
%end

%list
