× 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 generator
  • From: "Leland, David" <dleland@xxxxxxxxxx>
  • Date: Thu, 18 Dec 1997 09:33:59 -0500

Try this ILE RPG code.  It uses the CEERAN0 API.  If you want a 5 digit
random number simply call this program passing in a valuie of 10000 for
MINNBR and 99999 for MAXNBR and it will pass back to you the RNDNBR. 
Works for us.  Check out the documentation on the CEERAN0 API for info
on it's "seed" parameter.  We simply initialize it to 0.  You may want
to do it differently.  As always, comes w/ no guarantee and user is
responsible for thorough testing before using.


H*****************************************************************
D*** DATA DEFINITIONS                                             
D C0SEED          S              5I 0 INZ(0)                      
D C0RNDNBR        S              8F                               
D RNDNBR          S              9P 0                             
D MINNBR          S              9P 0                             
D MAXNBR          S              9P 0                             
C*****************************************************************
C*          MAIN LINE CALCULATIONS                                
C*****************************************************************
C*** ENTRY PARMS                                                  
C     *ENTRY        PLIST                                         
C                   PARM                    MINNBR                
C                   PARM                    MAXNBR                
C                   PARM                    RNDNBR                
C*** CALL API TO RETRIEVE NUMBER
C                   DOU       RNDNBR >= MINNBR                       
C                   CALLB     'CEERAN0'                              
C                   PARM                    C0SEED                   
C                   PARM                    C0RNDNBR                 
C                   PARM                    *OMIT                    
C*** RETRIEVE RANDOM NUMBER                                          
C                   EVAL      RNDNBR = %DECH(C0RNDNBR:30:29) * MAXNBR
C                   ENDDO                                            
C*** EXIT                                                            
C                   RETURN                                           

>----------
>From:  boothm@ibm.net[SMTP:boothm@ibm.net]
>Sent:  Wednesday, December 17, 1997 7:40 PM
>To:    MIDRANGE-L@midrange.com
>Subject:       re: Random Number generator
>
>I need to generate a random 5-digit number on an AS/400.  What is good?
>
>Is this a Rexx job?
>
>----------------------------------------------------
>Booth Martin     
>---------------------------------------------------
>
>
>
>+---
>| This is the Midrange System Mailing List!
>| To submit a new message, send your mail to "MIDRANGE-L@midrange.com".
>| To unsubscribe from this list send email to
>MIDRANGE-L-UNSUB@midrange.com.
>| Questions should be directed to the list owner/operator:
>david@midrange.com
>+---
>
+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to "MIDRANGE-L@midrange.com".
| To unsubscribe from this list send email to MIDRANGE-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.