× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: Random Number in PRG: example
  • From: "Paul Cunnane" <paul@xxxxxxxxxxx>
  • Date: Wed, 25 Apr 2001 13:57:10 +0100

Caveat: every time you run this, you will get the same sequence of `random'
numbers.  To get more truly pseudo-random numbers, seed the generator with
(say) the result of the TIME opcode.

I also tried this code without seeding the generator (commented out the
callp srand line), and got different, random-looking number sequences.
Maybe this is the best approach?

--
Paul

----- Original Message -----
From: "DeLong, Eric" <EDeLong@Sallybeauty.com>
To: <RPG400-L@midrange.com>
Sent: Tuesday, April 24, 2001 9:01 PM
Subject: RE: Random Number in PRG: example


> Ugh! That might work ok, but it's a bit dated..... If you're using RPGIV,
> give this a spin.
>
> ---------------------------------------------------------------
> H dftactgrp(*no) bnddir('QC2LE')
> D rand            pr            10i 0 extproc('rand')
> D srand           pr                  extproc('srand')
> D                               10i 0 value
> D num             s             10i 0
> D i               s             10i 0
> C                   callp     srand(123)
> C                   for       i = 1 to 10
> C                   eval      num = rand
> C     num           dsply
> C                   endfor
> C                   eval      *inlr = *on
> ----------------------------------------------------------------
>
>
> This was right out of the archives (thanks Hans). SRAND seeds the random
> generator, and RAND returns the random numbers. MUCH  simpler than the
> RPGIII code you found.
>
> hth,
> Eric DeLong


+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.