APPX is the Premier Development and Runtime Environment for Business Application Software
(Answer) (Category) FAQ's - APPX Software, Inc. : (Category) APPX Utility : (Category) APPX Development Environment : (Category) Tips & Techniques :
Example of a random number generator using ILF!
The follow sample will work for any range of numbers where the total numbers
in the range is a maximum of 10,000 (eg., 1 - 10000, 50000 - 60000, 
1678  -11678).  If you use a larger range, you will need to increase the
generating time (TI) by some factor to allow at least one full pass through
the range of numbers.

 
     *        Set start and end of desired number range.
     SET      --- AI                         =      1
     SET      --- ZI                         =      10000
     *        Use current time to get random number of seconds & hundredths
     *        (WORK RGEN TIME SS defined as date field with seconds only)
     *        (WORK RGEN TIME TH defined as date field with hundredths only)
     SET DATE 1EX WORK RGEN TIME SS
     SET      --- SI                         =  1EX WORK RGEN TIME SS
     SET DATE 1EX WORK RGEN TIME TH
     SET      --- TI                         =  1EX WORK RGEN TIME TH
     *        Add number of seconds to number of hundredths
     COMPUTE  --- TI                         +  --- SI
     IF       --- TI                         LT     1
T    SET      --- TI                         =      1
     *        Set Number counter to one less than specified start of range.
     SET      --- NI                         =  --- AI
     COMPUTE  --- NI                         -      1
     *        Calculate time to stop generator by starting at current time
     *        and increasing it by adding the value in TI to the th's part.
     *        (WORK RGEN RUN END defined as date field with YY thru th)
     SET DATE 1EX WORK RGEN RUN END
     DATE ADD 1EX WORK RGEN RUN END          1  --- TI
     *        Start infinite loop that will exit when end time is reached.
     BEG LOOP LI = 001 TO 001  STEP 000
     COMPUTE  --- NI                         +      1
     *        If number count reaches end of range, go back to start.
     IF       --- NI                         GT --- ZI
T    SET      --- NI                         =  --- AI
     *        If current time has reached end time, exit loop.
     *        (WORK RGEN RUN START defined as date field with YY thru th)
     SET DATE 1EX WORK RGEN RUN START
     IF       1EX WORK RGEN RUN START        GE 1EX WORK RGEN RUN END
F    END LOOP LI
     *          ==>  Resulting generated number is in ---NI
[Append to This Answer]
2004-Jan-02 4:14pm
Previous: (Answer) GUI themes via ILF!
Next: (Answer) How to retrieve an occurrence number with ILF!
This document is: http://board.appx.com/cgi-bin/fom.cgi?file=267
[Search] [Appearance]
This is a Faq-O-Matic 2.719.
Copyright 2003 by APPX Software, Inc. All rights reserved.