shellghost
Programmer
Does anyone know of a way to get a random number (or close to it) using AS/400 COBOL? I'm looking for a way to randomly choose 25 people from a file and that seems to be the way to go.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
000001 IDENTIFICATION DIVISION.
000002 PROGRAM-ID. RAND.
000003 ENVIRONMENT DIVISION.
000004 DATA DIVISION.
000005 WORKING-STORAGE SECTION.
000006 01 CURRENT-X.
000007 02 CURRENT-TIME PIC X(6).
000008 02 CURRENT-DATE PIC X(6).
000009 01 CURRENT-Y REDEFINES CURRENT-X.
000010 02 CURR01 PIC X.
000011 02 CURR02 PIC X.
000012 02 CURR03 PIC X.
000013 02 CURR04 PIC X.
000014 02 CURR05 PIC X.
000015 02 CURR06 PIC X.
000016 02 CURR07 PIC X.
000017 02 CURR08 PIC X.
000018 02 CURR09 PIC X.
000019 02 CURR10 PIC X.
000020 02 CURR11 PIC X.
000021 02 CURR12 PIC X.
000022 01 CURRENT-9 PIC 9(9) VALUE 0.
000023 01 CURRENT-R REDEFINES CURRENT-9.
000024 02 RAND-NUMBER PIC 9999.
000025 02 FILLER PIC X.
000026 02 CURR06 PIC X.
000027 02 CURR04 PIC X.
000028 02 CURR12 PIC X.
000029 02 CURR05 PIC X.
000030****************************************
000031 PROCEDURE DIVISION.
000032 0. ACCEPT CURRENT-TIME FROM TIME.
000033 ACCEPT CURRENT-DATE FROM DATE.
000034 MOVE CORR CURRENT-Y TO CURRENT-R.
000035 MULTIPLY 65535 BY CURRENT-9.
000036 DISPLAY RAND-NUMBER.
DIVIDE RAND-NUMBER BY N GIVING I REMAINDER REM.
ADD 1 TO REM.