|
Peter, Typically with random numbers, you use the random number returned on the first call to the API as the SEED value for the second call to the API and so on. Bob Cozzi cozzi@rpgiv.com Visit the on-line Midrange Developer forum at: http://www.rpgiv.com > -----Original Message----- > From: rpg400-l-admin@midrange.com [mailto:rpg400-l-admin@midrange.com] On > Behalf Of Peter Colpaert > Sent: Wednesday, January 16, 2002 1:14 AM > To: RPG400-L@midrange.com > Subject: Random number generation > > Hi, > > I am having some trouble using the CEERAN0 API for generating random > numbers. > > The problem is that I do get back some random numbers, but every time I run > the program, it's the same 'random' numbers that are generated. > > Maybe I'm just overlooking some trivial thing, but here's (part of) the > code. I want to generate 3 random numbers between 1 and 6, and use them to > set on 3 indicators between 11-16, 21-26 and 31-36. > > D S S 2s 0 > d indic s 2s 0 > * > D C0SEED S 5I 0 Inz(0) > d C0RNDNBR S 8F > > c movea '000000' *in(11) > c movea '000000' *in(21) > c movea '000000' *in(31) > * > C DOU S >= 1 and s < 7 > C CALLB 'CEERAN0' > C PARM C0SEED > C PARM C0RNDNBR > C PARM *OMIT > C EVAL S = %DECH(C0RNDNBR:30:29) * 7 > C ENDDO > * > c eval indic = 10 + s > c eval *in(indic) = *on > * > C DOU S >= 1 and s < 7 > C CALLB 'CEERAN0' > C PARM C0SEED > C PARM C0RNDNBR > C PARM *OMIT > C ENDDO > * > c eval indic = 20 + s > c eval *in(indic) = *on > * > C DOU S >= 1 and s < 7 > C CALLB 'CEERAN0' > C PARM C0SEED > C PARM C0RNDNBR > C PARM *OMIT > C EVAL S = %DECH(C0RNDNBR:30:29) * 7 > C ENDDO > * > c eval indic = 30 + s > c eval *in(indic) = *on > > Any suggestions would be highly appreciated. > > Peter Colpaert > Application Developer > Honda Europe NV > ---------- > Program documentation is like sex: when it is good, it is very, very good; and > when it is bad, it is better than nothing. > ---------- > > _______________________________________________ > This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list > To post a message email: RPG400-L@midrange.com > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l > or email: RPG400-L-request@midrange.com > Before posting, please take a moment to review the archives > at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
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.