Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ucbvax!hplabs!hpfcso!bigelow From: bigelow@hpfcso.HP.COM (Jim Bigelow) Newsgroups: comp.lang.pascal Subject: Re: HP Pascal: How to implement random number generator? Message-ID: <9110023@hpfcso.HP.COM> Date: 11 Jan 91 18:49:38 GMT References: <10889@uhccux.uhcc.Hawaii.Edu> Organization: Hewlett-Packard, Fort Collins, CO, USA Lines: 39 > I am using HP Pascal and wanted to use a random generator function, > just as in Turbo Pascal. Much to my surprise, the manual does not > contain any such function! Please e-mail any sugestion. Try calling the Unix (HP-UX) function rand from your pascal program as in the following example. Best Regards, Jim Bigelow Pascal Colorado Lang. Lab. HP Ft. Collins, CO ----- { Title: random.p -- generate random numbers by calling libc routine rand(3C) Last Mod: Fri Jan 11 11:35:00 1991 Author: Jim Bigelow } program random (input,output); var i : integer; seed : integer; function rand : integer; external; procedure srand(seed:integer); external; begin write('Enter seed: '); read(seed); srand(seed); for i := 1 to 10 do writeln(i,rand); end. {random}