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



Not sure if the following will help?  
pass the number of record in the file to the maxRandomNum.

PgetRandom        B                                              
D GetRandom       pi            15  5                            
D maxRandomNum                  15  5 const                      
 *                                                               
D RandNum         s             15  5                            
D RandFloat8      s              8f   inz                        
D RandInt4        s             10i 0 inz static                 
D RandAlpha8      s              8a   inz                        
 *                                                               
C                   callb(d)  'CEERAN0'                          
C                   parm                    RandInt4             
C                   parm                    RandFloat8           
C                   parm                    RandAlpha8           
C                   eval      RandNum=(maxRandomNum * RandFloat8)
 *                                                               
C                   return    RandNum                            
PGetRandom        E                 
                             

-----Original Message-----
Hans Boldt wrote:

First, get the number of records in the file. After the file is opened, 
the number is in position 156-159 in the INFDS.

Next, use your favorite method to compute random numbers (such as the C 
runtime library function "rand()"), and convert them to the range 
computed in the first step. Compute as many as you need, checking for 
duplicates.

Finally, read the records by relative record number.



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.