10-31-2004, 08:18 PM
I can't randomize (i.e. shuffle) the data inputted from the file below.
The data always will display in order from the file. Can I randomize it?
CLS
DEFDBL A-Z
CONST itema = 6
CONST itemb = 7
DIM A(1 TO itema) AS INTEGER
DIM b(1 TO itemb) AS INTEGER
PRINT : PRINT "initial draw:";
FOR A = 1 TO itema
A(A) = A
PRINT A(A);
NEXT A
RANDOMIZE TIMER ' must be outside loop
h = 0
OPEN "data.txt" FOR INPUT AS #1
DO WHILE NOT EOF(1)
h = h + 1
INPUT #1, b(h)
LOOP
CLOSE #1
PRINT
' I want the contents of file displayed below, in random order
' not in same order it is listed in the file.
PRINT : PRINT "random draw: ";
FOR b = 1 TO itemb
PRINT b(b);
NEXT b
'end of program
The file data.txt contains the following 7 datum in this order:
5
2
2
1
3
7
1
The data always will display in order from the file. Can I randomize it?
CLS
DEFDBL A-Z
CONST itema = 6
CONST itemb = 7
DIM A(1 TO itema) AS INTEGER
DIM b(1 TO itemb) AS INTEGER
PRINT : PRINT "initial draw:";
FOR A = 1 TO itema
A(A) = A
PRINT A(A);
NEXT A
RANDOMIZE TIMER ' must be outside loop
h = 0
OPEN "data.txt" FOR INPUT AS #1
DO WHILE NOT EOF(1)
h = h + 1
INPUT #1, b(h)
LOOP
CLOSE #1
' I want the contents of file displayed below, in random order
' not in same order it is listed in the file.
PRINT : PRINT "random draw: ";
FOR b = 1 TO itemb
PRINT b(b);
NEXT b
'end of program
The file data.txt contains the following 7 datum in this order:
5
2
2
1
3
7
1