× 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: "York, Albert" <albert.york@xxxxxxxxxxxxxx>
  • Date: Wed, 25 Apr 2001 09:49:23 -0700

You could include the current date or the job number as well as the time in
your seed.

Albert York     
        


        "DeLong, Eric" wrote:
        > 
        > True, I added the time seed shortly after posting the example, and
I too
        > realized that Hans' example was repeating sequences.  It also
occurs to me
        > that seeding by TIME (6.0) could be a bad idea is the program runs
at the
        > same time every night (scheduled job). It's not hard to imagine
the same
        > seed value being used repeatedly...... perhaps something more
random like
        > milliseconds....
        > 
        > Eric DeLong
        > 
        > -----Original Message-----
        > From: Paul Cunnane [mailto:paul@cunnane.net]
        > Sent: Wednesday, April 25, 2001 7:57 AM
        > To: RPG400-L@midrange.com
        > Subject: Re: Random Number in PRG: example
        > 
        > 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
        +---

        +---
        | 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
        +---
+---
| 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 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.