TIP: Click on subject to list as thread! ANSI
echo: quik_bas
to: PETER DALTON
from: DAVID WILLIAMS
date: 1998-04-22 10:17:00
subject: using RND

-> DW> 130 DIM A%(49)
-> doesn't this set all elements of the array to zero?
In most BASICs, yes. Maybe in all that are used nowadays. But I do
remember the old Atari BASIC in which freshly-DIMmed arrays contained
random-looking numbers, probably derived from the previous contents of
that chunk of memory.
But does it matter? In the next few lines of the program, I filled the
array with numbers.
->  DW>  180 ' start of shuffling loop
-> erm, doesn't this use a 'loop' of some kind   :-)
This big loop allows the user to generate a whole lot of lottery picks.
If he hits "y" in response to the "Another selection?" prompt, the
program goes back to the start of this loop. But it does *not* re-do the
stuff that came earlier, such as filling the array. I wanted to
demonstrate that repeating this was unnecessary.
->
-> DW> 200 ' shuffle random 6 numbers into first 6 positions
-> um, what for?
um, because the program is simulating a lottery, which picks six random
numbers.
->
-> DW> 210   FOR X% = 1 TO 6 DW> 220      Y% = INT((48) * RND) + 1
-> ok, how about using your loop as modified above then
->
-> IF A%(Y%)  0 then 220 A%(Y%)=1 NEXT
Nope. Frankly, I haven't a clue what you think this will achieve.
Did you try running the program, as I wrote it? It does work. Did you
then try modifying it? Did it still work?
                          dow
--- PCBoard (R) v15.3 (OS/2) 5
---------------
* Origin: FidoNet: CAP/CANADA Support BBS : 416 287-0234 (1:250/710)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.