× 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 # Generator for Cobol or RPG?
  • From: "Ray Harris" <rharris@xxxxxxxxxx>
  • Date: Wed, 15 Nov 2000 13:53:15 -0600
  • Importance: Normal

Examples:

       Identification Division.
       Program-Id.  randfractn.
       Environment Division.
       CONFIGURATION SECTION.
       SPECIAL-NAMES.
           LINKAGE PROCEDURE FOR "CEERAN0" USING ALL DESCRIBED.
       Input-Output Section.
       File-Control.
       Data Division.
       File Section.
       Working-Storage Section.
       01  seed Pic s9(9) Binary Value 0.
       Linkage Section.
       01  random-fraction comp-2.
       Procedure Division Using
           random-fraction
           .
       mainline.
           Call PROCEDURE "CEERAN0" Using
               seed
               random-fraction
           End-Call

           Goback
           .
       End Program randfractn
       .

       Identification Division.
       Program-Id.  randfractt.
       Environment Division.
       Input-Output Section.
       File-Control.
       Data Division.
       File Section.
       Working-Storage Section.
       01  random-fraction comp-2.
       Procedure Division.
       mainline.
           perform test-one
           perform test-one
           perform test-one
           perform test-one
           perform test-one
           perform test-one
           Goback
           .
       test-one.
           Call "RANDFRACTN" Using
               random-fraction
           End-Call

           display random-fraction
           .
       End Program randfractt
       .
  
       Identification Division.
       Program-Id.  randintegr.
       Environment Division.
       Input-Output Section.
       File-Control.
       Data Division.
       File Section.
       Working-Storage Section.
       01  random-fraction comp-2.
       linkage section.
       01  random-integer-out pic 9(9).
       01  random-integer-max pic 9(9).
       01  did-it-work Pic x.
       Procedure Division using
           random-integer-out
           random-integer-max
           did-it-work
           .
       mainline.
           move "N" to did-it-work

           if random-integer-max not numeric
               display "max not numeric"
               goback
           end-if
           if random-integer-max < 1
               display "max < 1"
               goback
           end-if

           Call "RANDFRACTN" Using
               random-fraction
           End-Call

           compute random-integer-out rounded
                 = random-integer-max
                 * random-fraction

           if random-integer-out < random-integer-max
               add 1 to random-integer-out
           end-if

           goback
           .
       End Program randintegr
       .

      Identification Division.
       Program-Id.  randintegt.
       Environment Division.
       Input-Output Section.
       File-Control.
       Data Division.
       File Section.
       Working-Storage Section.
       01  random-integer-out pic 9(9).
       01  random-integer-max pic 9(9).
       01  did-it-work Pic x.
       Procedure Division.
       mainline.
           move 10 to random-integer-max
           perform test-one
           move 100 to random-integer-max
           perform test-one
           move 1000 to random-integer-max
           perform test-one
           move 10000 to random-integer-max
           perform test-one
           move 100000 to random-integer-max
           perform test-one
           move 1000000 to random-integer-max
           perform test-one
           move 10000000 to random-integer-max
           perform test-one
           move 100000000 to random-integer-max
           perform test-one
           goback
           .
       test-one.
           perform 5 times

               call procedure "RANDINTEGR" using
                   random-integer-out
                   random-integer-max
                   did-it-work
               end-call

               display "between 1 and " random-integer-max
                       " : "            random-integer-out
                       " " did-it-work
           end-perform
           .
       copy randintegr in qgpl-qcbllesrc.
       End Program randintegt
       .
> -----Original Message-----
> From: owner-cobol400-l@midrange.com
> [mailto:owner-cobol400-l@midrange.com]On Behalf Of VADIM DOBRENKO
> Sent: Wednesday, November 15, 2000 10:09 AM
> To: beasley@alumni.auburn.edu; COBOL400-L@midrange.com
> Subject: Re:Random # Generator for Cobol or RPG?
> 
> 
>     CEERAN0
> 
> (LAST CHAR. IS ZERO)
> 
> Vadim
> ____________________Reply Separator____________________
> Subject:    Random # Generator for Cobol or RPG?
> Author: beasley@alumni.auburn.edu
> Date:       11/14/2000 10:01 PM
> 
> 
> Do you know of an API, procedure, or code that can be called or
> incorporated into my program to generate random numbers?
> Byron
> 
> +---
> | This is the COBOL/400 Mailing List!
> | To submit a new message, send your mail to COBOL400-L@midrange.com.
> | To subscribe to this list send email to COBOL400-L-SUB@midrange.com.
> | To unsubscribe from this list send email to 
> COBOL400-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner/operator: 
> david@midrange.com
> +---END
> 
> +---
> | This is the COBOL/400 Mailing List!
> | To submit a new message, send your mail to COBOL400-L@midrange.com.
> | To subscribe to this list send email to COBOL400-L-SUB@midrange.com.
> | To unsubscribe from this list send email to 
> COBOL400-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner/operator: 
> david@midrange.com
> +---END
> 
+---
| This is the COBOL/400 Mailing List!
| To submit a new message, send your mail to COBOL400-L@midrange.com.
| To subscribe to this list send email to COBOL400-L-SUB@midrange.com.
| To unsubscribe from this list send email to COBOL400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---END


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.