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

On (18 Apr 98) David Williams wrote to All...
Hi David,
 DW> I've noticed a lot of code posted here recently that doesn't look too
 DW> great to me.  In particular, a lot of people seem to use loops that
 DW> generate RNDs over and over again until some criterion is satisfied.
 DW> This is (almost) *never* necessary!
far be it from me to even hint at the possibility of a criticism...
but...
 DW> 130 DIM A%(49)
doesn't this set all elements of the array to zero?
 DW> 180 ' start of shuffling loop
erm, doesn't this use a 'loop' of some kind   :-)
 DW> 200 ' shuffle random 6 numbers into first 6 positions
um, what for?
 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

the numbers will be different and there's no need to sort them as you
simply read each element of the array from 1 upwards and if the element
value is non-zero you print the element number.
Success
Peter
--- PPoint 1.88
---------------
* Origin: Peter Points at last! (2:254/60.26)

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™.