I've been fiddling with this a bit more and now have something
that appears to work 90% of the time.
IDENTIFICATION DIVISION.
PROGRAM-ID. Random-mod-disps.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 mod-disp PIC Z9.
01 seed PIC 999V999.
01 temp PIC 999V.
01 div PIC 99.
01 mod PIC 99.
88 mod-is-10 value 10.
PROCEDURE DIVISION.
Main.
MOVE FUNCTION RANDOM(FUNCTION SECONDS-PAST-MIDNIGHT) TO
seed.
PERFORM FOREVER
PERFORM Generate-And-Display-mod-disp
IF mod-is-10
EXIT PERFORM
ELSE
PERFORM Generate-And-Display-mod-disp
END-IF
END-PERFORM
STOP RUN.
.
Generate-And-Display-mod-disp.
COMPUTE temp = FUNCTION RANDOM * 100.
DIVIDE temp BY 20 GIVING div REMAINDER mod.
MOVE mod TO mod-disp.
DISPLAY mod " " mod-disp.
.
Compiled with $ cobc -x -free -I/usr/local/include
-L/usr/local/lib breakloop.cob
The other 10% is where a run calculates a mod of 10 but does not
exit the perform, viz
address@hidden ~/open-cobol-1.1
$ breakloop.exe
05 5
02 2
03 3
00 0
12 12
10 10
11 11
12 12
08 8
13 13
15 15
19 19
19 19
11 11
02 2
09 9
05 5
14 14
15 15
15 15
10 10
Please note the 6th line which says that mod contains 10 and
mod-disp contains 10. Instead of terminating then, the program
continues on until it hits another 10 10 pair and *then* it
terminates.
What's going on here?
Bruce.
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2_______________________________________________
open-cobol-list mailing list
address@hiddenhttps://lists.sourceforge.net/lists/listinfo/open-cobol-list