home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / pascal / passrc / random.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-11-18  |  2.2 KB  |  71 lines

  1. { -----------------------------------------------------------------------------
  2.  
  3.                                  NOTICE:
  4.  
  5.       THESE MATERIALS are UNSUPPORTED by OSS!  If you do not understand how to
  6.       use them do not contact OSS for help!  We will not teach you how to 
  7.       program in Pascal.  If you find an error in these materials, feel free
  8.       to SEND US A LETTER explaining the error, and how to fix it.
  9.  
  10.       THE BOTTOM LINE:
  11.  
  12.          Use it, enjoy it, but you are on your own when using these materials!
  13.  
  14.  
  15.                                DISCLAIMER:
  16.  
  17.       OSS makes no representations or warranties with respect to the contents
  18.       hereof and specifically disclaim all warranties of merchantability or
  19.       fitness for any particular purpose.   This document is subject to change
  20.       without notice.
  21.       
  22.       OSS provides these materials for use with Personal Pascal.  Use them in
  23.       any way you wish.
  24.  
  25.    -------------------------------------------------------------------------- }
  26.  
  27.  
  28. {***************************************************************************
  29.  
  30.         Random number routines for Personal Pascal
  31.  
  32.         October 1, 1986 MJC
  33.         Copyright 1986 OSS
  34.  
  35.         { Will not compile as-is!  Include this file in your program... }
  36.  
  37. *****************************************************************************}
  38.  
  39.  
  40. Function XB_Rnd : Long_Integer; { get xbios random 24-bit number }
  41.    Xbios( 17 );
  42.  
  43. (***************************************************************************
  44.  
  45.         Function Rnd returns a real number in the range of 0 to 1.
  46.  
  47. ****************************************************************************)
  48.  
  49. Function Rnd : Real;
  50.  
  51.    Begin
  52.       Rnd := XB_Rnd / 16777216.0;
  53.    End;
  54.  
  55.  
  56. (****************************************************************************
  57.  
  58.         Function Random takes a low and high range and returns a random
  59.         integer that falls between Low and Hi.
  60.  
  61. ****************************************************************************)
  62.  
  63. Function Random( Low, Hi : Integer ) : Integer;
  64.  
  65.    Begin
  66.       Random := Low + Trunc( Rnd * ( Hi - Low +1 ) );
  67.    End;
  68.  
  69. { END OF RANDOM.PAS }
  70.  
  71.